showSnackBar static method

void showSnackBar(
  1. BuildContext context, {
  2. required String message,
  3. String? actionText,
  4. Function? actionCallBack,
})

Implementation

static void showSnackBar(BuildContext context,
    {required String message, String? actionText, Function? actionCallBack}) {
  if (!context.mounted) return;
  final snackBar = SnackBar(
    content: Text(message),
    action: actionText != null
        ? SnackBarAction(
            label: actionText,
            onPressed: () {
              actionCallBack?.call();
            },
          )
        : null,
  );

  // Find the ScaffoldMessenger in the widget tree
  // and use it to show a SnackBar.
  ScaffoldMessenger.of(context).showSnackBar(snackBar);
}