I have written my custom theme like this and stored it in Get storage.
class Themes {
static final lightTheme = ThemeData(
brightness: Brightness.light,
colorScheme: const ColorScheme.light(),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
textStyle: TextStyle(
color: CustomColor.lightLandingScreenTextColor,
),
),
),
);
static final darkTheme = ThemeData(
brightness: Brightness.dark,
colorScheme: const ColorScheme.dark(),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
backgroundColor: Colors.red,
textStyle: TextStyle(
color: CustomColor.darkLandingScreenTextColor,
),
),
),
);
}
Then I tried to apply my outlinedbutton theme on my outlinedbutton like this
SizedBox(
height: 48.h,
width: 155.w,
child: OutlinedButton(
onPressed: () {},
child: Text("SKIP"),
style: OutlinedButton.styleFrom(),
),)
I also tried to assign theme like this but this gave me an error.
Now how can I assign that custom button theme in my button? I am using GetX for state management.
Try to use like this
style: context.theme.outlinedButtonTheme.style
you are trying to add OutlinedButtonThemeData
in a parameter type 'ButtonStyle?'
that's why giving error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.