Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cancel() works only on the 1st time #512

Open
subzero911 opened this issue Jun 19, 2024 · 2 comments
Open

cancel() works only on the 1st time #512

subzero911 opened this issue Jun 19, 2024 · 2 comments

Comments

@subzero911
Copy link

subzero911 commented Jun 19, 2024

I want to cancel the toast everytime I press the key.

But it works only on the 1st time, next toasts are not cancelled:

bad.toast.video_2024-06-19_15-02-19.mp4

code:

@override
  void initState() {
    super.initState();
    nameTextController = TextEditingController()
      ..addListener(() async {
        if (nameTextController.text.length > 40) {
          await Fluttertoast.cancel();
          Fluttertoast.showToast(msg: 'Max 40 characters').ignore();
        }
      });
  }
@jongkb
Copy link

jongkb commented Nov 4, 2024

I'm noticing this too on Android 14. However, on Android 10, cancel() works as expected on repeated calls.

@davidd7
Copy link

davidd7 commented Nov 4, 2024

I'm also having this problem on Android 14. One workaround I've found is calling cancel multiple times. For example, the problem doesn't appear for me for short toasts when always calling cancel 10 times:

  for (int i = 0; i < 10; i++) {
    await Fluttertoast.cancel();
  }

This is of course a rather ugly workaround and it would be better if the underlying problem would be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants