Closed tuanbs closed 3 years ago
you can use isShowing() from here https://github.com/cmdrootaccess/another-flushbar/blob/d0b51947ffd184a0deb68a86bf38f7de78b57707/lib/flushbar.dart#L285
@cmdrootaccess Got it. Thank you very much.
@cmdrootaccess can you provide me an example please, because i can't get it to run
define bool variable in the class
bool isSnackbarActive = false;
void showWarningFlushBar(
BuildContext context,
String content, {
String? title,
}) {
if (!isSnackbarActive) {
isSnackbarActive = true;
Flushbar(
flushbarPosition: FlushbarPosition.TOP,
borderRadius: BorderRadius.circular(16),
margin: const EdgeInsets.all(8),
title: title ?? LocaleKeys.common_warning.locale,
messageText: Text(
content,
maxLines: 3,
style: const TextStyle(color: Colors.white),
),
duration: const Duration(seconds: 2),
backgroundGradient: LinearGradient(begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [
Colors.orange.shade600,
Colors.amber.shade700,
])).show(context).then((value) {
isSnackbarActive = false;
});
}
}
I'd like to check if flushbar is already open before showing a new one. Otherwise, the new one overlaps the old one. Something like this:
Thanks in advance.