how can I fix this error in flutter with android studio
/C:/src/flutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.6.3/lib/get_navigation/src/snackbar/snackbar.dart:452:31: Error: Method ‘addPostFrameCallback’ cannot be called on ‘SchedulerBinding?’ because it is potentially null.
- ‘SchedulerBinding’ is from ‘package:flutter/src/scheduler/binding.dart’ (‘/C:/src/flutterSDK/flutter/packages/flutter/lib/src/scheduler/binding.dart’).
Try calling using ?. instead.
SchedulerBinding.instance.addPostFrameCallback(
^^^^^^^^^^^^^^^^^^^^
4
Answers
This error is due to some changes happened in null-safety properties in Flutter 3.0.0. In your case you can try to import:
get: 4.6.1
instead ofget: ^4.6.3
.Source: https://github.com/jonataslaw/getx/issues/2356
This error happens because the package get 4.6.2 or 4.6.3 is for new flutter sdk version 3.0. So you got this error. you have to use get 4.6.1 for fluter SDK version 2.xx
I had the same problem.. on "dart.get" package. Then I did this..
if the version won’t get lower then try this method
you will find in pubspec.lock file
and last you have to do this
This is because of recent flutter updates. All flutter
SDKs >= V2.10.3
have this issue. There’s no proper solution for this error yet.Temporary Solution:
You can simply downgrade your flutter SDK to
V2.10.2
or lower to get rid of this issue.Note:
After downgrading, make sure you also change the dart version in pubspec.yaml of your flutter project according to the Flutter SDK.
try this