snackBar function

dynamic snackBar(
  1. BuildContext context, {
  2. required String? text,
  3. Color? bgColor,
  4. bool? isFLoating,
  5. String? actionLabel,
  6. VoidCallback? actionPress,
})

Implementation

snackBar(BuildContext context,
    {required String? text,
    Color? bgColor,
    bool? isFLoating,
    String? actionLabel,
    VoidCallback? actionPress}) {
  ScaffoldMessenger.of(context).hideCurrentSnackBar();
  ScaffoldMessenger.of(context).showSnackBar(SnackBar(
    behavior: isFLoating != null
        ? isFLoating
            ? SnackBarBehavior.floating
            : SnackBarBehavior.fixed
        : SnackBarBehavior.fixed,
    backgroundColor: bgColor,
    content: Text(text!),
    action: actionLabel == null
        ? null
        : SnackBarAction(
            label: actionLabel,
            disabledTextColor: Colors.white,
            textColor: Colors.yellow,
            onPressed: actionPress ?? () {},
          ),
  ));
}