notify static method

Future<void> notify(
  1. String message, {
  2. TextAlign? textAlign,
  3. TextStyle? textStyle,
  4. SnackBarAction? action,
  5. Duration duration = const Duration(seconds: 5),
  6. Duration actionDuration = const Duration(seconds: 10),
  7. bool removeCurrentSnackBar = true,
})

Implementation

static Future<void> notify(
  String message, {
  TextAlign? textAlign,
  TextStyle? textStyle,
  SnackBarAction? action,
  Duration duration = const Duration(seconds: 5),
  Duration actionDuration = const Duration(seconds: 10),
  bool removeCurrentSnackBar = true,
}) async {
  final snackBar = SnackBar(
    content: Text(
      message,
      textAlign: textAlign ?? TextAlign.center,
      style: textStyle ??
          const TextStyle(
            color: Colors.white,
            fontWeight: FontWeight.w600,
          ),
    ),
    action: action,
    duration: action != null ? actionDuration : duration,
    elevation: 0,
    behavior: SnackBarBehavior.floating,
  );
  if (removeCurrentSnackBar) {
    notificationServiceSnackBarKey.currentState?.removeCurrentSnackBar();
  }
  notificationServiceSnackBarKey.currentState?.showSnackBar(snackBar);
}