The following NoSuchMethodError was thrown building MyApp(dirty, state: _MyAppState#86032):

Issue

I get this error message and have no idea how to fix it:

Exception caught by widgets library
The following NoSuchMethodError was thrown building MyApp(dirty, state: _MyAppState#86032):

The method 'call' was called on null.

Receiver: null

Tried calling: call(Instance of 'ChangeNotifierProvider<UserLoggedIn>')```

And this is the code that’s the cause of this problem:

void main() {
    runApp(ProviderScope(child:MyApp()));
 }

class MyApp extends StatefulHookWidget {

 @override
 _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp>

I thought I should change the current flutter version I use because this happened when I updated flutter, but that didn’t work.

Solution

Sounds like you may have updated flutter to a version that has null safety.
When this happens, methods cannot be null even if in the previous version of flutter it was ok and ran.
Take a look at these references:
Null Safety

Migration

Answered By – Nick C.

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.