3

After upgrading to 3.0.0. i keep getting this error about WidgetsBinding.instance!.addPostFrameCallback((_) {

here is the image of the error. enter image description here

1

2 Answers 2

2

change

WidgetsBinding.instance!.addPostFrameCallback((_) {});

to

WidgetsBinding.instance.addPostFrameCallback((_) {});

You can also run dart fix --apply from the command line which will make the above change for you automatically.

The return type of WidgetsBinding.instance was changed from static WidgetsBinding? get instance => ... to static WidgetsBinding get instance => ... so adding ! or ? is no longer required.

Also, note that this is just a warning, and you may get the warning from dependencies if they also have an unnecessary ? or !.

See also Flutter 3.0.0 release notes - If you see warnings about bindings.

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

6 Comments

i have try this dart fix --apply, but not working.... still having the same issue
@GbengaBAyannuga It could be that packages your app depends on have not been updated, in which case you will have to wait for them to update the packages and then update your dependencies in your pubspec.yaml file. In the meantime you can simply ignore the warnings, the app should compile and run even if these warnings are present.
@GbengaBAyannuga looking at the error message, it looks like the warning is coming from the states_rebuilder package. You could try reaching out to them on github and ask them to update the package to fix this warning, and then updating your version of states_rebuilder when they fix this issue. Also, the most recent version appears to be 6.1.0, I would try upgrading to 6.1.0 first to see if the issue still exists in that version.
@GbengaBAyannuga actually, It looks like they have already updated the library. github.com/GIfatahTH/states_rebuilder/pull/269 I would try upgrading states_rebuilder to the latest version in your pubspec.
i am even unable to run the app. The app is not running because of the error..
|
1

That will not work but you can move the '?' to read:

WidgetsBinding.instance?.addPostFrameCallback((_) {});

Instead of

WidgetsBinding?.instance.addPostFrameCallback((_) {});

1 Comment

Sorry similar problem ... ups

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.