Flutter GetX Custom Theme for Button


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

  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.

enter image description here

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.

Answered By – masum billah sanjid

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *