mirror of
https://github.com/friebetill/TubeCards.git
synced 2025-08-14 01:35:57 +08:00
56 lines
1.4 KiB
Dart
56 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'themes/custom_theme.dart';
|
|
|
|
extension CustomSnackBars on ScaffoldMessengerState {
|
|
/// Displays a snackbar containing a success [text].
|
|
///
|
|
/// The color of the snack bar indicates a success.
|
|
void showSuccessSnackBar({
|
|
required String text,
|
|
required ThemeData theme,
|
|
Duration duration = const Duration(seconds: 4),
|
|
SnackBarAction? snackBarAction,
|
|
}) {
|
|
removeCurrentSnackBar();
|
|
|
|
showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
text,
|
|
style: TextStyle(color: theme.snackBarTheme.actionTextColor),
|
|
),
|
|
action: snackBarAction,
|
|
backgroundColor: theme.custom.successColor,
|
|
duration: duration,
|
|
behavior: SnackBarBehavior.floating,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Displays a snackbar containing an error [text].
|
|
///
|
|
/// The color of the snack bar indicates an error.
|
|
void showErrorSnackBar({
|
|
required String text,
|
|
required ThemeData theme,
|
|
Duration duration = const Duration(seconds: 4),
|
|
SnackBarAction? snackBarAction,
|
|
}) {
|
|
removeCurrentSnackBar();
|
|
|
|
showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
text,
|
|
style: TextStyle(color: theme.snackBarTheme.actionTextColor),
|
|
),
|
|
action: snackBarAction,
|
|
backgroundColor: theme.colorScheme.error,
|
|
duration: duration,
|
|
behavior: SnackBarBehavior.floating,
|
|
),
|
|
);
|
|
}
|
|
}
|