I’m developping my first app with Flutter and Firebase. I built it one time, far before connecting it to Firebase. Now I have done it at 90% but I can’t build the apk and not able to correct to error caused while building it. I need help.
This is the error :
C:UsersAsusflutterbinflutter.bat --no-color build apk
Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Running Gradle task 'assembleRelease'...
../../flutter/.pub-cache/hosted/pub.dartlang.org/charts_flutter-0.12.0/lib/src/chart_container.dart:205:27: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
if (!SchedulerBinding.instance!.hasScheduledFrame) {
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/charts_flutter-0.12.0/lib/src/chart_container.dart:206:24: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
SchedulerBinding.instance!.scheduleFrame();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/charts_flutter-0.12.0/lib/src/chart_container.dart:209:22: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
SchedulerBinding.instance!.addPostFrameCallback(startAnimationController);
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/charts_flutter-0.12.0/lib/src/chart_container.dart:232:22: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
SchedulerBinding.instance!.addPostFrameCallback(doRebuild);
^
Thank you
2
Answers
I saw the problem, the fact is the plugin charts_flutter is deprecated on the version of flutter that I have. So I drop it out and the type of error never print again. Even if my app isn't okay yet, because of other kind of error.
Some changes happened in null-safety properties at the last upgrade of Flutter 3.0.0. There are a few approaches to a solution.
1-) Upgrade to latest version of flutter. It will solve your issue.
2-) If you upgraded the latest Flutter version and if your error is in the Flutter Core codes you must try;
(Ref: https://docs.flutter.dev/development/tools/sdk/release-notes/release-notes-3.0.0)
3-) If this solution doesn’t fix any error you can downgrade the Flutter version;
4-) If you didn’t upgrade or the error is in the third-party package;
The developer of this package may have upgraded this package to the recent version of Flutter. You can upgrade packages with;
If the developer hasn’t upgraded yet, you must go to this package’s Github repo and look at the issue tab. Maybe someone opened an issue and the dev answered the correct running version. For example, GetX’s latest compatible version with Flutter 2.10.5 is 4.6.1. So for applying this version you can just use the version constraint (remove ˆ).
Update
to
in your pubspec.
(Ref: https://github.com/jonataslaw/getx/issues/2356)