showSnackBar static method

void showSnackBar({
  1. required BuildContext context,
  2. required String message,
  3. Duration duration = const Duration(seconds: 3),
  4. bool isError = false,
})

Exibe uma mensagem de feedback rápido (SnackBar)

Implementation

static void showSnackBar({
  required BuildContext context,
  required String message,
  Duration duration = const Duration(seconds: 3),
  bool isError = false,
}) {
  final theme = SyncThemeProvider.current;
  final messenger = ScaffoldMessenger.of(context);

  messenger.hideCurrentSnackBar();
  messenger.showSnackBar(
    SnackBar(
      content: Text(
        message,
        style: theme.bodyStyle.copyWith(
          color: Colors.white,
        ),
      ),
      backgroundColor: isError ? theme.error : theme.primary,
      duration: duration,
      behavior: SnackBarBehavior.floating,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(8),
      ),
    ),
  );
}