/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/fluttertoast-8.1.3/lib/fluttertoast.dart:165:28: Error: Member not found: 'Overlay.maybeOf'.
var _overlay = Overlay.maybeOf(context!);
^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/fluttertoast-8.1.3/lib/fluttertoast.dart:154:18: Error: The getter 'mounted' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
framework.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'mounted'.
if (context?.mounted != true) {
^^^^^^^
3
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159
在我的项目中添加fluttertoast后,当我在设备上运行项目时,它显示了这个问题。现在,它意味着什么?
我试图显示吐司时,一个错误或成功发生。但没有snackbar fluttertoast是唯一的选择这样做。但添加依赖关系后,这个问题显示。
2条答案
按热度按时间gr8qqesn1#
Flutter toast
v8.1.3
无法与3.7.0之前的Flutter版本一起工作,因为Flutter v3.7.0
中存在breaking change。您必须使用fluttertoast v8.1.2
,或者必须将flutter版本升级到v3.7.0
+。我在运行
flutter pub upgrade
后遇到了类似的问题,但即使在回滚pubspec.yaml
文件中的更改后,我也得到了相同的错误。但在回滚pubspec.lock
文件中的更改后,这个问题得到了修复。请确保在还原pubspec.lock
文件中的更改后执行flutter clean
。bvhaajcl2#
试着用这个:
如果你有任何问题我都可以回答
快乐的编码。