Flutter 3.0 shows error : WidgetsBinding.instance!.addPostFrameCallback((_) => widget.onReady.call());
'WidgetsBinding.instance' getter used to be a nullable type. In the new update it is changed to a Non-nullable. So, now old packages show this after the update because they used null aware operator there. It will be fixed in the new versions. For now you can just remove the null aware operator from the lines that show up in the logs and after rebuild there will be no more warnings.
amit.flutter
Currently working as an iOS and Flutter developer at Karmaleen Technology.
Updated on December 02, 2022Comments
-
amit.flutter over 1 year
After the upgrade project in flutter 3.0 it shows the following error.
Syncing files to device iPhone 13 Pro Max... ../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/another_transformer_page_view-1.1.0/lib/src/another_transformer_page_view.dart:519:22: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Developer/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance!.addPostFrameCallback(_onGetSize); ^ ../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/another_transformer_page_view-1.1.0/lib/src/another_transformer_page_view.dart:537:22: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Developer/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance!.addPostFrameCallback(_onGetSize); ^ ../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_login-3.2.0/lib/src/widgets/animated_text.dart:57:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Developer/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance!.addPostFrameCallback((_) { ^ ../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/awesome_select-5.2.0/lib/src/widget.dart:1547:58: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Developer/flutter/packages/flutter/lib/src/widgets/binding.dart'). MediaQueryData.fromWindow(WidgetsBinding.instance!.window); ^ ../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/awesome_select-5.2.0/lib/src/text_error.dart:99:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Developer/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance!.addPostFrameCallback((_) {
it's bug from flutter? Can anyone report this to flutter. i don't know to report this to flutter team.
This Warning bug is resolved. see my comment in correct answer I have written ( if you are a mac user goto finder -> press goto button by swift+cmd+G -> past all 6 files I have mentioned or you find an error and replace [root-name] with your root directory name.
-
Hardik Mehta almost 2 yearstry to do flutter clean , flutter pub update and cd ios and pod install and try
-
-
amit.flutter almost 2 yearsI make changes as per your suggestion but it's not working. Error is still same
-
amit.flutter almost 2 yearsi am already Using: cached_network_image: ^3.2.1
-
Xuann Thucc almost 2 yearsthese warnings are just warnings. Very annoying, but still compiling and running fine.
-
amit.flutter almost 2 yearsOkay, Thank you. Let me know if there is solution to remove this warning.
-
amit.flutter almost 2 yearsYes, it's just warning i have removed the null operator from each file where the error is showing.
-
amit.flutter almost 2 yearsfor mac user press : Swift + window/CMD key + G ( open goto file dialog) and past this files path
-
amit.flutter almost 2 years1) /Users/[root-name]/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_login-3.2.0/lib/src/widgets/animated_text.dart
-
amit.flutter almost 2 years2) /Users/[root-name]/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/another_transformer_page_view-1.1.0/lib/src/another_transformer_page_view.dart
-
amit.flutter almost 2 years3) /Users/[root-name]/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/awesome_select-5.2.0/lib/src/widget.dart
-
amit.flutter almost 2 years4) /Users/[root-name]/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/awesome_select-5.2.0/lib/src/text_error.dart
-
amit.flutter almost 2 years5) /Users/[root-Name]/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/awesome_select-5.2.0/lib/src/modal.dart
-
amit.flutter almost 2 years6) /Users/[root-name]/Developer/flutter/packages/flutter/lib/src/widgets/binding.dart