13

When I try to run the application on android with "flutter run" in terminal, I am getting the following error...

/C:/Users/Acer/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/delegate_widget.dart:194:18: Error: Superclass has no method named 'inheritFromElement'.
    return super.inheritFromElement(ancestor, aspect: aspect);
                 ^^^^^^^^^^^^^^^^^^
/C:/Users/Acer/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/provider.dart:259:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/D:/Flutter/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
        ? context.inheritFromWidgetOfExactType(type) as InheritedProvider<T>
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/Users/Acer/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/provider.dart:260:19: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/D:/Flutter/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorInheritedElementForWidgetOfExactType'.
        : context.ancestorInheritedElementForWidgetOfExactType(type)?.widget
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/Users/Acer/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with 
the name 'nullOk'.
        context != null ? Localizations.localeOf(context, nullOk: true) : null,
                                                          ^^^^^^
/D:/Flutter/flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
  static Locale localeOf(BuildContext context) {
                ^^^^^^^^
                                                                        

FAILURE: Build failed with an exception.

* Where:
Script 'D:\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

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

* 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 1m 50s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                       121.0s
Exception: Gradle task assembleDebug failed with exit code 1

The thing is that yesterday it was working properly, but today it is showing this error message. Kindly help solve it.

3
  • Check your flutter channel. I change mine to stable and it worked. Also, upgrade to the latest flutter version. Commented Feb 1, 2021 at 17:27
  • I encountered a similar issue. Downgrading flutter solved the problem. Commented Feb 3, 2021 at 8:25
  • Please accept the answer that solved your problem. It will help others who are looking for a solution, too. Commented Feb 14, 2021 at 7:56

9 Answers 9

11

Update the provider version 4.3.3 it will resolve the issue

Sign up to request clarification or add additional context in comments.

1 Comment

@PinkeshDarji Great
2

Edit - With flutter 2 out, it will not work. The answer is now obsolete

Had this issue when I switched to master channel. Had to downgrade

flutter channel stable && flutter upgrade

fixed the issue

Comments

2

I had the same problem for the past 3 days. If you don't want to go with the downgraded flutter version, I still have a solution: First, update your flutter version in case if you had downgrade it using:

flutter upgrade

in your terminal.

As you can notice in the debug console that you're working with provider

version 3.2.0

from the error output. I think if you use a version of provider greater than

version 4.0.0

Simply replace provider: ^3.2.0 with provider: ^4.0.0

(you can adjust this in the pubspec.yaml file)

then it will work.

Give that a go and let me know if that resolves the issue :)

Comments

1

Simply replace provider: ^3.2.0 with provider: ^4.0.0 and it work for me (you can adjust this in the pubspec.yaml file)

Comments

0

You probably upgraded flutter in a channel other than 'stable'. In that case, the easiest solution would be to simply open a terminal and run (type) flutter downgrade.

1 Comment

Just change provider version it will resolve the issue
0

Please upgrade your dependencies to the latest one. I find the solution by myself. This error occurred due to copying the complete code, which is made on an older version, now the latest version has null safety enabled, so this is the reason for the problem.

Comments

0

Update the provider version 4.3.3 it will resolve the issue

and if it gives you a null safety error, edit your configurations in the run tab on Andriod studio and on the additional run args add this:-

--no-sound-null-safety

and click on apply.

this will for sure clear your errors

Comments

0

try updating the provider version to 4.0.0 or higher. I was having the same issue and updating the provider version resolved my issue

Comments

0

FOR ME

updating provider version from 3.0.0 to 4.3.3 works, also change argument name from builder to create.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.