show method

void show({
  1. String? title,
  2. double? titleSize,
  3. required String text,
  4. double? textSize,
  5. required SnackType snackType,
  6. Duration? duration,
  7. required BuildContext context,
})

Implementation

void show({
  String? title,
  double? titleSize,
  required String text,
  double? textSize,
  required SnackType snackType,
  Duration? duration,
  required BuildContext context,
}) {
  if (showing == true) return;

  Flushbar(
    titleText: title != null
        ? Text(
            title.toString(),
            style: TextStyle(
              color: Colors.white,
              fontSize: titleSize ?? 17,
              fontWeight: FontWeight.bold,
            ),
          )
        : null,
    messageText: Text(
      text,
      style: TextStyle(
        color: Colors.white,
        fontSize: textSize,
      ),
    ),
    icon: Icon(
      snackType == SnackType.info
          ? Icons.info
          : (snackType == SnackType.success
              ? Icons.check
              : (snackType == SnackType.warning
                  ? Icons.warning
                  : Icons.error)),
      size: 20,
      color: Colors.white,
    ),
    shouldIconPulse: false,
    backgroundColor: snackType == SnackType.info
        ? const Color(0xFF0E9FFF)
        : (snackType == SnackType.success
            ? Colors.green
            : (snackType == SnackType.warning
                ? const Color(0xFFCC6332)
                : Colors.red)),
    duration: const Duration(seconds: 3),
    boxShadows: const [
      BoxShadow(color: Colors.grey, offset: Offset(0.0, 2.0), blurRadius: 3.0)
    ],
    onStatusChanged: (status) {
      switch (status) {
        case FlushbarStatus.SHOWING:
          {
            break;
          }
        case FlushbarStatus.IS_APPEARING:
          {
            showing = true;
            notifyListeners();
            break;
          }
        case FlushbarStatus.IS_HIDING:
          {
            break;
          }
        case FlushbarStatus.DISMISSED:
          {
            showing = false;
            notifyListeners();
            break;
          }
        default:
          {
            break;
          }
      }
    },
  ).show(context);
}