skip to Main Content

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:srcflutterpackagesflutter_toolsgradleflutter.gradle' line: 991

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:srcflutterbinflutter.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!

2

Answers


  1. 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

    Login or Signup to reply.
  2. 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>();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search