最近,我的调试控制台显示了一些以前没有显示的东西。当我使用flutter_typeahead
包时会发生这种情况。我不知道这是错误还是警告。下面是我的调试控制台:
Launching lib\main.dart on Chrome in debug mode...
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.removeObserver(this);
^
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.addObserver(this);
^
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.addPostFrameCallback((duration) {
^
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.removeObserver(this);
^
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.addObserver(this);
^
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.addPostFrameCallback((duration) {
^
This app is linked to the debug service: ws://127.0.0.1:60355/d-7F-zZtGz0%3D/ws
Debug service listening on ws://127.0.0.1:60355/d-7F-zZtGz0=/ws
Running with sound null safety
Connecting to VM Service at ws://127.0.0.1:60355/d-7F-zZtGz0=/ws
如果有人能提供建议,不胜感激。提前感谢!
6条答案
按热度按时间h43kikqp1#
如果您正在升级到较新版本,可能会弹出此类警告,因为它们与较新版本不兼容。您可以忽略它。此警告将消失!
pod7payv2#
这应该是一个非致命的警告。我忽略了它。
qyswt5oh3#
在工作室将Flutter更新到最新版本后,我也得到了同样的错误(我想我不小心在吐司中按错了按钮)。
在我的例子中,项目太大了,结果是更容易下载以前版本的Flutter(https://docs.flutter.dev/development/tools/sdk/releases),只需替换Flutter文件夹中的文件。
hfsqlsce4#
检查您拥有的Flutter版本并检查通道:
flutter --version
flutter channel
flutter channel stable
然后做
flutter upgrade
。它可能会解决你的问题,它对我有效,希望这对你也有效。ujv3wf0j5#
我的flutter版本是3.0.0,我关注了这篇文章:https://docs.flutter.dev/development/tools/sdk/release-notes/release-notes-3.0.0来修复它们。
Ctrl +单击DEBUG CONSOLE中的flare_render_box.dart链接将其打开。在flare_render_box.dart文件中:
T?_ambiguate(T?value)=〉value;
1.替换“SchedulerBinding.instance?.cancelFrameCallbackWithId(_frameCallbackID);“与
_ambiguate(SchedulerBinding.instance)!.cancelFrameCallbackWithId(_frameCallbackID);
1.替换“SchedulerBinding.instance?.cancelFrameCallbackWithId(_frameCallbackID);“与
_ambiguate(SchedulerBinding.instance)!.cancelFrameCallbackWithId(_frameCallbackID);
_frameCallbackID = _ambiguate(SchedulerBinding.instance)!.scheduleFrameCallback(_beginFrame);
1.然后保存它并重建您的应用程序。
6rqinv9w6#
这在我看来不像是一个错误。自从Dart升级到null-safety后,它会警告你这个包的一些类还没有升级到null-safety。我最近在我的项目中使用了这个包,但我没有收到这个警告。很可能你使用的是旧版本的包。我想让你做几件事。首先,转到
pubspec.yaml
文件并检查flutter_typeahaed
的版本。如果它比版本3.2.4旧,请像下面这样更新它。然后,在终端中分别键入以下命令。
问题最有可能出现在
flutter_typeahed
包版本中。