Closed mqhamdam closed 3 years ago
Flushbar _flush = new Flushbar( ... );
/// Show flushbar _flush.show(context);
/// Hide flushbar _flush.dismiss();
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;
});
}
}
Good day! I didnt find any method to programmatically close the current flushbar. There is a solution for snackbars (ScaffoldMessenger.of(context)..hideCurrentSnackbar()..showSnackbar(); .... how to implement this with flushbar?