Open Nabinda opened 1 year ago
@Nabinda thanks for filling this issue I will check it
+1, I've experienced same problem.
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:
Will wait for the update, great package by the way.
@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(),));
}
});
}
Its bad to show a success toast while its still in loading phase so i believe this hot fix is still not that reliable
@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
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();
});
@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 toastexample:
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: https://github.com/koukibadr/Motion-Toast/issues/100#issuecomment-1524961392
@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
It loos like Auto poping pages issue is still there am I wrong? I'm using latest version 2.6.7
@koukibadr tried again it's ok there is no old problem, thanks for hot fix
@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.
@codewithmustafa okay I will check it
@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();
});
@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.
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