Flutter:空感知操作的操作数'!'具有类型 'WidgetsBinding' ,不包括 null
Flutter : Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null
我 运行 我的 flutter 应用程序(Flutter 3.0 和 dart sdk 2.17.0.
但是现在我在这里发现了一个警告,像这样-
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_navigation/src/router_report.dart:53:22: Warning: Operand of null-aware
operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/widgets/bindi
ng.dart').
WidgetsBinding.instance!.addPostFrameCallback((_) {
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_navigation/src/snackbar/snackbar.dart:452:22: Warning: Operand of
null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance!.addPostFrameCallback(
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_navigation/src/extension_navigation.dart:357:24: Warning: Operand of
null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance!.addPostFrameCallback((_) {
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_navigation/src/extension_navigation.dart:468:24: Warning: Operand of
null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance!.addPostFrameCallback((_) {
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_state_manager/src/simple/get_controllers.dart:90:20: Warning: Operand
of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/widgets/bindi
ng.dart').
WidgetsBinding.instance!.addObserver(this);
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_state_manager/src/simple/get_controllers.dart:96:20: Warning: Operand
of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/widgets/bindi
ng.dart').
WidgetsBinding.instance!.removeObserver(this);
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_state_manager/src/rx_flutter/rx_notifier.dart:130:22: Warning: Operand
of null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) => onReady());
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_state_manager/src/rx_flutter/rx_disposable.dart:20:22: Warning: Operand
of null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) => onReady());
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/overlay_entry.dart:35:26: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
if (SchedulerBinding.instance?.schedulerPhase ==
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/overlay_entry.dart:37:24: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) {
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/container.dart:64:24: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.schedulerPhase ==
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/container.dart:101:24: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) => completer
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/container.dart:112:24: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) => completer
^
Syncing files to device iPhone SE (3rd generation)... 805ms
这是什么问题。之前版本的flutter没有显示
在 Flutter 3.0 中
SchedulerBinding.instance!.addPostFrameCallback(...);
成为
SchedulerBinding.instance.addPostFrameCallback(...);
似乎绑定包内部编码了一些调度程序绑定,需要更新。
您可以将包复制到本地并更改该包中的代码。
或者更改依赖项....或者等到该包更新并恢复到 Flutter 2.10.5
您可以阅读 Flutter 3.0 的变化Here
我用了一个改版本的工具Flutter Sidekick你可以为不同的项目选择不同的Flutter版本。
我 运行 我的 flutter 应用程序(Flutter 3.0 和 dart sdk 2.17.0.
但是现在我在这里发现了一个警告,像这样-
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_navigation/src/router_report.dart:53:22: Warning: Operand of null-aware
operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/widgets/bindi
ng.dart').
WidgetsBinding.instance!.addPostFrameCallback((_) {
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_navigation/src/snackbar/snackbar.dart:452:22: Warning: Operand of
null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance!.addPostFrameCallback(
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_navigation/src/extension_navigation.dart:357:24: Warning: Operand of
null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance!.addPostFrameCallback((_) {
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_navigation/src/extension_navigation.dart:468:24: Warning: Operand of
null-aware operation '!' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance!.addPostFrameCallback((_) {
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_state_manager/src/simple/get_controllers.dart:90:20: Warning: Operand
of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/widgets/bindi
ng.dart').
WidgetsBinding.instance!.addObserver(this);
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_state_manager/src/simple/get_controllers.dart:96:20: Warning: Operand
of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/widgets/bindi
ng.dart').
WidgetsBinding.instance!.removeObserver(this);
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_state_manager/src/rx_flutter/rx_notifier.dart:130:22: Warning: Operand
of null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) => onReady());
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.
6.1/lib/get_state_manager/src/rx_flutter/rx_disposable.dart:20:22: Warning: Operand
of null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) => onReady());
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/overlay_entry.dart:35:26: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
if (SchedulerBinding.instance?.schedulerPhase ==
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/overlay_entry.dart:37:24: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) {
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/container.dart:64:24: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.schedulerPhase ==
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/container.dart:101:24: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) => completer
^
/usr/local/Caskroom/flutter/2.0.2/flutter/.pub-cache/hosted/pub.dartlang.org/flutte
r_easyloading-3.0.3/lib/src/widgets/container.dart:112:24: Warning: Operand of
null-aware operation '?.' has type 'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart'
('/usr/local/Caskroom/flutter/2.0.2/flutter/packages/flutter/lib/src/scheduler/bin
ding.dart').
SchedulerBinding.instance?.addPostFrameCallback((_) => completer
^
Syncing files to device iPhone SE (3rd generation)... 805ms
这是什么问题。之前版本的flutter没有显示
在 Flutter 3.0 中
SchedulerBinding.instance!.addPostFrameCallback(...);
成为
SchedulerBinding.instance.addPostFrameCallback(...);
似乎绑定包内部编码了一些调度程序绑定,需要更新。
您可以将包复制到本地并更改该包中的代码。
或者更改依赖项....或者等到该包更新并恢复到 Flutter 2.10.5
您可以阅读 Flutter 3.0 的变化Here
我用了一个改版本的工具Flutter Sidekick你可以为不同的项目选择不同的Flutter版本。