I was using Flutter version 1.25 (beta channel) and it worked just fine. After upgrading to version 2.0.0 and switching to stable channel i'm getting this error when i try to run the app either on mobile or web.
../../../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);
^^^^^^^^^^^^^^^^^^
../../../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' ('/C:/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>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../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' ('/C:/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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unhandled exception:
NoSuchMethodError: The getter 'name' was called on null.
Receiver: null
Tried calling: name
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1 ProgramCompiler._emitSuperTarget (package:dev_compiler/src/kernel/compiler.dart:5109:41)
#2 ProgramCompiler.visitSuperMethodInvocation (package:dev_compiler/src/kernel/compiler.dart:5102:24)
#3 SuperMethodInvocation.accept (package:kernel/ast.dart:5109:44)
#4 ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:3623:20)
#5 ProgramCompiler.visitAsExpression (package:dev_compiler/src/kernel/compiler.dart:5677:18)
#6 AsExpression.accept (package:kernel/ast.dart:6062:44)
#7 ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:3623:20)
#8 ProgramCompiler.visitReturnStatement (package:dev_compiler/src/kernel/compiler.dart:4152:38)
#9 ReturnStatement.accept (package:kernel/ast.dart:7786:43)
#10 ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3551:20)
#11 MappedListIterable.elementAt (dart:_internal/iterable.dart:411:31)
#12 ListIterator.moveNext (dart:_internal/iterable.dart:340:26)
#13 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)
#14 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#15 new List.of (dart:core-patch/array_patch.dart:50:28)
#16 ListIterable.toList (dart:_internal/iterable.dart:211:44)
#17 ProgramCompiler.visitBlock (package:dev_compiler/src/kernel/compiler.dart:3717:62)
#18 Block.accept (package:kernel/ast.dart:7048:43)
#19 ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3551:20)
#20 ProgramCompiler._emitFunctionScopedBody (package:dev_compiler/src/kernel/compiler.dart:3562:18)
#21 ProgramCompiler._emitSyncFunctionBody.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:3355:17)
#22 ProgramCompiler._withLetScope (package:dev_compiler/src/kernel/compiler.dart:2235:25)
#23 ProgramCompiler._withCurrentFunction (package:dev_compiler/src/kernel/compiler.dart:3389:18)
#24 ProgramCompiler._emitSyncFunctionBody (package:dev_compiler/src/kernel/compiler.dart:3351:17)
#25 ProgramCompiler._emitFunction (package:dev_compiler/src/kernel/compiler.dart:3165:11)
#26 ProgramCompiler._emitMethodDeclaration (package:dev_compiler/src/kernel/compiler.dart:1843:12)
#27 ProgramCompiler._emitClassMethods (package:dev_compiler/src/kernel/compiler.dart:1784:23)
#28 ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:658:21)
#29 ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:580:21)
#30 List.forEach (dart:core-patch/growable_array.dart:403:8)
#31 ProgramCompiler._emitLibrary (package:dev_compiler/src/kernel/compiler.dart:529:23)
#32 List.forEach (dart:core-patch/growable_array.dart:403:8)
#33 ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:394:15)
#34 JavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:144:33)
<asynchronous suspension>
#35 FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:632:5)
<asynchronous suspension>
#36 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:545:9)
<asynchronous suspension>
#37 listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1105:11)
<asynchronous suspension>
Finished with error: the Dart compiler exited unexpectedly.
Failed to compile application.
I tried (from Android Studio) Tools > Flutter > Flutter Clean
and File > Invalidate Caches / Restart...
but it didn't help.
dart fix
to to migrate your Flutter project. – Apealeddart fix --dry-run
and it saidNothing to fix!
– Jrawatprovider
package is several versions out of date. You are on version3.2.0
when the most recent release is5.0.0
. The older package is likely incompatible with the Flutter 2.0.0. – Apealeddart fix --dry-run
should be executed from the Flutter SDK directory (I first executed it from my project directory) – Jrawatdart
to rundart fix
with the--dry-run
command:v2.12
. H – Apealed