Globally edit color of TextButton widgets in an AppBar actions list?
468
You are using TextButton
in your AppBar but not defining its theme in your code. You need to define the TextButtonTheme in order to change the color of the text of your TextButton. Like this.
ThemeData(
textbuttonTheme: TextbuttonThemeData(
style: Textbutton.styleFrom(primary: Colors.teal)),
),
Author by
user1087973
Updated on December 27, 2022Comments
-
user1087973 over 1 year
In my root file I have:
theme: ThemeData( appBarTheme: AppBarTheme( textTheme: TextTheme( button: TextStyle(color: Colors.white), ), ), ),
and in my custom AppBar file:
return AppBar( automaticallyImplyLeading: false, backgroundColor: Colors.transparent, actions: <Widget>[ TextButton( child: Text('Sign in'), onPressed: () {}, ), ], );
but the text remains the default light blue-ish color.
-
vietstone over 2 yearsThis affects all other TextButton. Is there any way to change the color of TextButton only in AppBar?
-
Usman Akhlaq over 2 yearsYes, The TextButton for which you want to change the color specifically just use its style property. This way the changes will be only for the specific button.