/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:srcflutterpackagesflutter_toolsgradleflutter.gradle' line: 1159
After adding fluttertoast in my project it shows this problem while I run project on my device.
Now, what does it mean?
I was trying to show toast when an error or success occurred. But without snackbar fluttertoast is the only option to do.
But after adding dependency this problem showed.
4
Answers
try to use this:
if you had any problem or question i’m here to answer.
happy coding.
Update: Found the actual issue:
Flutter toast
v8.1.3
cannot work with a Flutter version older than 3.7.0 because of a breaking change inFlutter v3.7.0
. You have to either usefluttertoast v8.1.2
or you have to upgrade your flutter version tov3.7.0
+.Old Answer
I faced a similar issue after running the
flutter pub upgrade
but even after rolling back the changes in thepubspec.yaml
file, I got the same error. But this issue was fixed after rolling back the changes in thepubspec.lock
file. Make sure to doflutter clean
after reverting changes inpubspec.lock
file.I also came across the same problem,
Due to some limitations I was not able to change the flutter version, and Changing the version of fluttertoast has not led to any success. so what I do is try some other alternatives
I removed fluttertoast completely from the project and install a new dependency by running the command in the terminal
usage:
Unfortunately, this error is caused by a version incompatibility between the fluttertoast package and your version of Flutter. The Overlay.maybeOf method was removed in Flutter 2.0 and replaced with Overlay.of, which is likely what the fluttertoast package is using.
In order to fix this error, you can try upgrading to the latest version of fluttertoast, or if that doesn’t work, downgrade your version of Flutter to a version compatible with the version of fluttertoast you are using.