import 'package:another_flushbar/flushbar.dart'; import 'package:another_flushbar/flushbar_route.dart' as flushRoute; import 'package:drifter/pages/widgets/flust_bar_type.dart'; import 'package:drifter/theme/app_colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; Future showFloatingFlushBar({ required FlushBarType type, required String message, String? iconAsset, required BuildContext context, Duration? duration = const Duration(milliseconds: 1500), FlushbarPosition flushbarPosition = FlushbarPosition.TOP, VoidCallback? onTap, }) { Color bg; Color fg; switch (type) { case FlushBarType.success: fg = AppColors.snackBarTextSuccess; bg = AppColors.snackBarBackSuccess; break; case FlushBarType.info: fg = AppColors.snackBarTextInfo; bg = AppColors.snackBarBackInfo; break; case FlushBarType.warning: fg = AppColors.snackBarTextError; bg = AppColors.snackBarBackError; break; } final bar = Flushbar( onTap: (_) { onTap?.call(); }, icon: iconAsset != null ? SvgPicture.asset( iconAsset, height: 16, width: 16, // color: fg, ) : null, message: message, messageColor: fg, flushbarPosition: flushbarPosition, backgroundColor: bg, duration: duration, flushbarStyle: FlushbarStyle.FLOATING, borderRadius: BorderRadius.circular( 8.0, ), margin: const EdgeInsets.all(20), maxWidth: MediaQuery.of(context).size.width - 50, ); final _route = flushRoute.showFlushbar( context: context, flushbar: bar, ); return Navigator.of(context, rootNavigator: true).push(_route); }