0

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.

2
  • Does it happen by making MyApp to statelessWidget or statefulWidget? Jan 24, 2022 at 15:48
  • Hey Yeasin, my problem still persists. It happens at statefulWidget. Feb 1, 2022 at 11:30

1 Answer 1

0

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

1
  • Hey Nick, I have migrated my code but the problem still persists. Feb 1, 2022 at 11:30

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.