koukibadr / Cherry-Toast

https://pub.dev/packages/cherry_toast
MIT License
21 stars 14 forks source link

Give the cancel function or if one toast is there then other toast should be below the first one. #74

Open someshswami9 opened 1 week ago

someshswami9 commented 1 week ago

I think there should be a cancel toast function which will work to cancel the toast and if that should not then there should be a option where toast should be seen one by one means show them below of another.

koukibadr commented 1 week ago

The best solution is to show the toasts stacked with each other thanks for the enhancement recommandation I'll work on it

someshswami9 commented 2 days ago

can you give me an example of how I can stack the toasts?

import 'package:cherry_toast/cherry_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:google_fonts/google_fonts.dart';

class Toasts {

void errorToast(BuildContext context, String msg){ if (context == null ) { return; } CherryToast.error( title: Text(msg, style: GoogleFonts.quattrocentoSans(fontWeight: FontWeight.w600, fontSize: 14,),), disableToastAnimation: true, displayCloseButton: false, borderRadius: 8, backgroundColor: Theme.of(context).brightness == Brightness.dark ? Colors.black: Colors.white , iconWidget: SvgPicture.asset("assets/icons/close-circle.svg"),

).show(context);

}

void successToast(BuildContext context, String msg){ if (context == null ) { return; } CherryToast.success( title: Text(msg, style: GoogleFonts.quattrocentoSans(fontWeight: FontWeight.w600, fontSize: 14,),), disableToastAnimation: true, displayCloseButton: false, borderRadius: 8, backgroundColor: Theme.of(context).brightness == Brightness.dark ? Colors.black: Colors.white , iconWidget: SvgPicture.asset("assets/icons/tick-circle.svg"),

).show(context);

}

void warningToast(BuildContext context, String msg){ if (context == null ) { return; } CherryToast.warning( title: Text(msg, style: GoogleFonts.quattrocentoSans(fontWeight: FontWeight.w600, fontSize: 14,),), disableToastAnimation: true, displayCloseButton: false, borderRadius: 8, toastDuration: const Duration(milliseconds: 1000), backgroundColor: Theme.of(context).brightness == Brightness.dark ? Colors.black: Colors.white , iconWidget: SvgPicture.asset("assets/icons/danger.svg"),

).show(context);

}

void infoToast(BuildContext context, String msg){ if (context == null ) { return; } CherryToast.info( title: Text(msg, style: GoogleFonts.quattrocentoSans(fontWeight: FontWeight.w600, fontSize: 14,),), disableToastAnimation: true, displayCloseButton: false, borderRadius: 8, backgroundColor: Theme.of(context).brightness == Brightness.dark ? Colors.black: Colors.white , iconWidget: SvgPicture.asset("assets/icons/info-circle.svg"),

).show(context);

}

}

when I call the Toasts.errorToast and it will automatically called from intrcepter when I get any error from API call please give the solution for stacking of the toasts.

koukibadr commented 2 days ago

@someshswami9 cherry package doesn't support stacking toasts, if it's a top priority for you I recommend using elegant_notification package it support stacking toasts and it contains basically the same features as cherry_toast the meanwhile I'm working on the stacking feature in this package