Skip to content

Commit 06c802a

Browse files
committed
refactor: move SnackBar theme properties to snackBarTheme in app_themes
1 parent 4849410 commit 06c802a

File tree

2 files changed

+17
-29
lines changed

2 files changed

+17
-29
lines changed

lib/style/app_themes.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ ThemeData getAppTheme(ColorScheme colorScheme) {
246246
color: effectiveColorScheme.outlineVariant,
247247
thickness: 1,
248248
),
249+
snackBarTheme: SnackBarThemeData(
250+
backgroundColor: effectiveColorScheme.secondaryContainer,
251+
contentTextStyle: TextStyle(
252+
color: effectiveColorScheme.onSecondaryContainer,
253+
fontWeight: FontWeight.w500,
254+
),
255+
behavior: SnackBarBehavior.floating,
256+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
257+
elevation: 6,
258+
actionTextColor: effectiveColorScheme.secondary,
259+
),
249260
visualDensity: VisualDensity.adaptivePlatformDensity,
250261
useMaterial3: true,
251262
pageTransitionsTheme: PageTransitionsTheme(

lib/utilities/flutter_toast.dart

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,13 @@ void showToast(
3232
}) {
3333
final colorScheme = Theme.of(context).colorScheme;
3434
final isMiniPlayerVisible = audioHandler.mediaItem.value != null;
35-
final bottomMargin = 12.0 + (isMiniPlayerVisible ? MiniPlayer.playerHeight : 0.0);
35+
final bottomMargin =
36+
12.0 + (isMiniPlayerVisible ? MiniPlayer.playerHeight : 0.0);
3637

3738
ScaffoldMessenger.of(context).showSnackBar(
3839
SnackBar(
39-
backgroundColor: colorScheme.secondaryContainer,
40-
behavior: SnackBarBehavior.floating,
41-
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
4240
margin: EdgeInsets.fromLTRB(16, 12, 16, bottomMargin),
4341
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
44-
elevation: 6,
4542
content: Row(
4643
children: [
4744
Icon(
@@ -50,15 +47,7 @@ void showToast(
5047
size: 20,
5148
),
5249
const SizedBox(width: 12),
53-
Expanded(
54-
child: Text(
55-
text,
56-
style: TextStyle(
57-
color: colorScheme.onSecondaryContainer,
58-
fontWeight: FontWeight.w500,
59-
),
60-
),
61-
),
50+
Expanded(child: Text(text)),
6251
],
6352
),
6453
duration: duration,
@@ -76,16 +65,13 @@ void showToastWithButton(
7665
}) {
7766
final colorScheme = Theme.of(context).colorScheme;
7867
final isMiniPlayerVisible = audioHandler.mediaItem.value != null;
79-
final bottomMargin = 12.0 + (isMiniPlayerVisible ? MiniPlayer.playerHeight : 0.0);
68+
final bottomMargin =
69+
12.0 + (isMiniPlayerVisible ? MiniPlayer.playerHeight : 0.0);
8070

8171
ScaffoldMessenger.of(context).showSnackBar(
8272
SnackBar(
83-
backgroundColor: colorScheme.secondaryContainer,
84-
behavior: SnackBarBehavior.floating,
85-
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
8673
margin: EdgeInsets.fromLTRB(16, 12, 16, bottomMargin),
8774
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
88-
elevation: 6,
8975
content: Row(
9076
children: [
9177
Icon(
@@ -94,20 +80,11 @@ void showToastWithButton(
9480
size: 20,
9581
),
9682
const SizedBox(width: 12),
97-
Expanded(
98-
child: Text(
99-
text,
100-
style: TextStyle(
101-
color: colorScheme.onSecondaryContainer,
102-
fontWeight: FontWeight.w500,
103-
),
104-
),
105-
),
83+
Expanded(child: Text(text)),
10684
],
10785
),
10886
action: SnackBarAction(
10987
label: buttonName,
110-
textColor: colorScheme.secondary,
11188
onPressed: () => onPressedToast(),
11289
),
11390
persist: false,

0 commit comments

Comments
 (0)