How can I set custom color for snackBar's label since it is defined as String?
final snackBar = SnackBar(
content: Text(_message),
action: SnackBarAction(
label: 'Close',
onPressed: () {},
),
);
You could change the color of the SnackBarAction label using the textColor parameter. Please see below for a code sample showing how this could be done.
final snackBar = SnackBar(
content: Text(_message),
action: SnackBarAction(
textColor: Colors.red,
label: 'Close',
onPressed: () {},
),
);
Alternatively, you could set the text color of all SnackBarAction labels using the global snackBarTheme parameter of the application's ThemeData.
return MaterialApp(
home: HomePage(),
theme: ThemeData(
snackBarTheme: SnackBarThemeData(
actionTextColor: Colors.red,
),
),
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With