forked from Nexus/nexus
treewide: small refactors
This commit is contained in:
parent
9117663c48
commit
8d944831f5
10 changed files with 63 additions and 63 deletions
28
lib/helpers/extensions/show_error_snack_bar.dart
Normal file
28
lib/helpers/extensions/show_error_snack_bar.dart
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import "package:material_ui/material_ui.dart";
|
||||
|
||||
extension ShowErrorSnackBar on ScaffoldMessengerState {
|
||||
/// Shows [message] in a snackbar styled as an error.
|
||||
ScaffoldFeatureController<SnackBar, SnackBarClosedReason> showErrorSnackBar(
|
||||
String message, {
|
||||
({String label, VoidCallback onPressed})? action,
|
||||
}) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return showSnackBar(
|
||||
.new(
|
||||
backgroundColor: colorScheme.errorContainer,
|
||||
content: Text(
|
||||
message,
|
||||
style: .new(color: colorScheme.onErrorContainer),
|
||||
),
|
||||
action: action == null
|
||||
? null
|
||||
: .new(
|
||||
label: action.label,
|
||||
onPressed: action.onPressed,
|
||||
textColor: colorScheme.onErrorContainer,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue