show method

void show(
  1. ScaffoldMessengerState state, {
  2. required String message,
  3. int duration = 1,
  4. bool isSuccess = true,
})

Implementation

void show(
  ScaffoldMessengerState state, {
  required String message,
  int duration = 1, // second
  bool isSuccess = true,
}) {
  state.removeCurrentSnackBar();
  SnackBar sn = SnackBar(
    content: Text(
      message,
      style: TextStyle(
        color: Colors.white,
        fontSize: FontSize.medium(),
      ),
    ),
    duration: Duration(seconds: duration),
    backgroundColor: isSuccess ? Colors.green : Colors.red,
  );

  state.showSnackBar(sn);
}