Home > database >  Flutter Compiling Debugging Error With Gradle
Flutter Compiling Debugging Error With Gradle

Time:12-13

Recently i am want running some old app from another open source but when trying to compile with the same SDK with pubspec.yaml but having this kind problem

., [12/12/2022 11:37 PM]
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.6.0/lib/flutter_redux.dart:77:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').

., [12/12/2022 11:37 PM]
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.

        ? context.inheritFromWidgetOfExactType(type)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.6.0/lib/flutter_redux.dart:79:14: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.

., [12/12/2022 11:37 PM]
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
package:flutter/…/widgets/framework.dart:1
Try correcting the name to the name of an existing method, or defining a method named 'ancestorInheritedElementForWidgetOfExactType'.
            .ancestorInheritedElementForWidgetOfExactType(type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_circular_chart-0.1.0/lib/src/animated_circular_chart.dart:122:10: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').

., [12/12/2022 11:38 PM]
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

., [12/12/2022 11:38 PM]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7m 25s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

I am still confuse what the solution is can you guys help? thank you for your guys help and advance God bless you all!

CodePudding user response:

Your package flutter_redux-0.6.0 is three years old!

It does not work with the current Flutter version any more.

Use version 0.10.0

CodePudding user response:

This is because the Flutter API changed slightly.

  • Now instead of using inheritFromWidgetOfExactType you have to use dependOnInheritedWidgetOfExactType
  • dependOnInheritedWidgetOfExactType takes Type as a generic.

From this:

final widget = context.inheritFromWidgetOfExactType(MyInheritedWidget) as MyInheritedWidget;

Migrated to:

final widget = context.dependOnInheritedWidgetOfExactType<MyInheritedWidget>();
  • Related