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

Auto poping pages #100

Open
Nabinda opened this issue Mar 30, 2023 · 16 comments
Open

Auto poping pages #100

Nabinda opened this issue Mar 30, 2023 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@Nabinda
Copy link

Nabinda commented Mar 30, 2023

When I show the toast message and navigate to another screen than it does navigate but after a few second toast message appear poping the screen taking me back from where i called toast

@koukibadr koukibadr added the bug Something isn't working label Mar 30, 2023
@koukibadr koukibadr self-assigned this Mar 30, 2023
@koukibadr
Copy link
Owner

@Nabinda thanks for filling this issue I will check it

@codewithmustafa
Copy link

+1, I've experienced same problem.

@codewithmustafa
Copy link

When I show the toast message and navigate to another screen than it does navigate but after a few second toast message appear poping the screen taking me back from where i called toast

For a workaround that works for now I did these 2 steps:

  • I made toast "not dismissable", it will dismiss itself
  • set toast duration to 1 sec so that it can gone faster for ux

Will wait for the update, great package by the way.

koukibadr added a commit that referenced this issue Apr 2, 2023
@koukibadr koukibadr reopened this Apr 2, 2023
@koukibadr
Copy link
Owner

@Nabinda I've published a new version with a hot fix for this problem
for now you can use the dismiss() function in your UI screen to close the toast

example:

late MotionToast resultToast;
  StreamController myStream = StreamController();

  void observeOnResult() {
    myStream.stream.listen((result) {
      if(result == Results.loading){
        resultToast = MotionToast.success(
      title: const Text(
        'Lorum Ipsum',
        style: TextStyle(fontWeight: FontWeight.bold),
      ),
      description: const Text(
        'Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor, sed do eiusmod tempor, sed do eiusmod tempor',
        style: TextStyle(fontSize: 12),
      ),
      layoutOrientation: ToastOrientation.rtl,
      animationType: AnimationType.fromRight,
      dismissable: true,
    );
      }else {
        resultToast.dismiss();
       Navigator.push(context, MaterialPageRoute(builder: (context) => const Scaffold(),));
      }
    });
  }

@koukibadr
Copy link
Owner

check the 2.6.6 version

@Nabinda
Copy link
Author

Nabinda commented Apr 11, 2023

Its bad to show a success toast while its still in loading phase so i believe this hot fix is still not that reliable

@koukibadr
Copy link
Owner

@Nabinda the example I put is only to understand the modifications you can make in your code.
the important part is the dismiss() function that you can call to manually close the toast from you UI screen

@olers
Copy link

olers commented Apr 27, 2023

I set dismissable: true,and set Future.delayed to use the toast.dismiss().

When the App was running and the toast appeared, I tapped the screen before the toast.dismiss() executed, and then it did dismiss. After that I tapped the screen and moved the mouse, my page dimissed.

    MotionToast toast = MotionToast(
      icon: Icons.zoom_out,
      primaryColor: Color.fromARGB(225, 0, 0, 0),
      secondaryColor: Colors.transparent,
      backgroundType: BackgroundType.solid,
      title: Text('Two ast\nToast\nToast\nToast\n\n\n', style: TextStyle(color: Colors.white),),
      description: Text('Another ',  style: TextStyle(color: Colors.white),),
      borderRadius: 6,
      barrierColor: Colors.black38,
      constraints: BoxConstraints(
        maxWidth: MediaQuery.of(context).size.width - 200,
        minWidth: MediaQuery.of(context).size.width - 200,
        maxHeight: MediaQuery.of(context).size.height - 200,
        minHeight: MediaQuery.of(context).size.height - 200,
      ),
      displaySideBar: false,
      position: MotionToastPosition.center,
      dismissable: true,
      toastDuration: Duration(days: 1),
    );
    toast.show(context);


    Future.delayed(Duration(seconds: 5)).then((value) {
      toast.dismiss();
    });

@olers
Copy link

olers commented Apr 27, 2023

@Nabinda I've published a new version with a hot fix for this problem for now you can use the dismiss() function in your UI screen to close the toast

example:

late MotionToast resultToast;
  StreamController myStream = StreamController();

  void observeOnResult() {
    myStream.stream.listen((result) {
      if(result == Results.loading){
        resultToast = MotionToast.success(
      title: const Text(
        'Lorum Ipsum',
        style: TextStyle(fontWeight: FontWeight.bold),
      ),
      description: const Text(
        'Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor, sed do eiusmod tempor, sed do eiusmod tempor',
        style: TextStyle(fontSize: 12),
      ),
      layoutOrientation: ToastOrientation.rtl,
      animationType: AnimationType.fromRight,
      dismissable: true,
    );
      }else {
        resultToast.dismiss();
       Navigator.push(context, MaterialPageRoute(builder: (context) => const Scaffold(),));
      }
    });
  }

If I tap the screen and the toast dismisses, after that the App coincidentally run the resultToast.dismiss(), then the page maybe will be aotu poped.

plz take a look: #100 (comment)

@koukibadr
Copy link
Owner

@olers checkout the newest version 2.6.7 I just fixed the issue
let me know if there's anything else
https://pub.dev/packages/motion_toast

@codewithmustafa
Copy link

It loos like Auto poping pages issue is still there am I wrong? I'm using latest version 2.6.7

@codewithmustafa
Copy link

@koukibadr tried again it's ok there is no old problem, thanks for hot fix

@codewithmustafa
Copy link

@koukibadr I should say, this problem still persists, although rarely.

To reproduce the issue: just tap fast and much when showing a motion toast. You will catch it.

When it does this if nav stack has only one page user come across a blank and black screen, which is so bad for user experience.

@koukibadr
Copy link
Owner

@codewithmustafa okay I will check it

@olers
Copy link

olers commented May 4, 2023

@olers checkout the newest version 2.6.7 I just fixed the issue let me know if there's anything else https://pub.dev/packages/motion_toast

the issue 'page aotu pop' seems was fixed, but neither the toast.dismiss() or toastDuration: Duration(days: 1), seems to be working anymore.

Here is the code.

MotionToast toast = MotionToast(
      icon: Icons.zoom_out,
      primaryColor: Color.fromARGB(225, 0, 0, 0),
      secondaryColor: Colors.transparent,
      backgroundType: BackgroundType.solid,
      title: Text('Two ast\nToast\nToast\nToast\n\n\n', style: TextStyle(color: Colors.white),),
      description: Text('Another ',  style: TextStyle(color: Colors.white),),
      borderRadius: 6,
      barrierColor: Colors.black38,
      constraints: BoxConstraints(
        maxWidth: MediaQuery.of(context).size.width - 200,
        minWidth: MediaQuery.of(context).size.width - 200,
        maxHeight: MediaQuery.of(context).size.height - 200,
        minHeight: MediaQuery.of(context).size.height - 200,
      ),
      displaySideBar: false,
      position: MotionToastPosition.center,
      dismissable: true,
      toastDuration: Duration(days: 1),
    );
    toast.show(context);


    Future.delayed(Duration(seconds: 5)).then((value) {
      toast.dismiss();
    });

@kcs-govindtank
Copy link

@koukibadr I should say, this problem still persists, although rarely.

To reproduce the issue: just tap fast and much when showing a motion toast. You will catch it.

When it does this if nav stack has only one page user come across a blank and black screen, which is so bad for user experience.

@koukibadr This is serious issue UX wise, facing the same thing what @codewithmustafa, If you can fix it properly, It would be really helpful. Thank You.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants