showFlushBar function
Implementation
Future<void> showFlushBar({
required bool value,
String textTrue = "",
String textFalse = "",
Duration? duration,
void Function()? onPressedMainButton,
String? textMainButton,
}) async {
try {
BuildContext context = ModernFormGlobalContext.context!;
Size size = ModernFormGlobalContext.size;
num webBreakdown = ModernFormUtils.webBreakdown;
late Flushbar flushbar;
bool mainButtonPressed = false;
flushbar = Flushbar(
maxWidth: size.width > webBreakdown ? size.width * .2 : null,
borderRadius: BorderRadius.circular(size.width > webBreakdown ? 8 : 0),
margin: EdgeInsets.only(
bottom: ScreenUtil().setHeight(size.width > webBreakdown ? 7 : 0)),
message: value ? textTrue : textFalse,
backgroundColor: value ? Colors.green : Colors.red,
icon: Icon(
value ? Icons.check : Icons.close,
color: Colors.white,
),
duration: duration ?? Duration(milliseconds: 1500),
reverseAnimationCurve: Curves.fastOutSlowIn,
mainButton: onPressedMainButton != null
? TextButton(
onPressed: () {
if (!mainButtonPressed) {
mainButtonPressed = true;
flushbar.dismiss();
onPressedMainButton();
}
},
child: Text(
textMainButton ?? "Desfazer",
style: TextStyle(
color: Colors.white, fontSize: ScreenUtil().setSp(14)),
),
)
: null,
);
await flushbar.show(context);
} catch (e, s) {
developer.log("", error: e, stackTrace: s);
}
}