createGBTheme function
ThemeData
createGBTheme({
- Color accentColor = DefaultColors.accent_accent_blue,
- Color accentError = DefaultColors.accent_error_red,
- Color accentErrorLight = DefaultColors.accent_error_red_light,
- Color backgroundBase = DefaultColors.background_base,
- Color backgroundContrast = DefaultColors.background_contrast,
- Color backgroundDisabled = DefaultColors.background_disabled,
- Color backgroundFocus = DefaultColors.background_focus,
- Color primaryColor = DefaultColors.primaryPrimaryYellow,
- Color textBase = DefaultColors.text_gray_base,
- Color textBlack = DefaultColors.text_text_black,
- Color textDisabled = DefaultColors.text_gray_disabled,
- Color textWhite = DefaultColors.text_text_white,
- TextTheme? textTheme,
- BorderRadius? textFieldRadius,
- double? textFieldBorderWidth,
- BorderRadius? buttonsRadius,
- InputDecorationThemeData? inputDecorationTheme,
- ElevatedButtonThemeData? elevatedButtonTheme,
- OutlinedButtonThemeData? outlinedButtonTheme,
- SwitchThemeData? switchTheme,
- ChipThemeData? chipTheme,
- bool useMaterial3 = true,
Base utility to create a standard Flutter ThemeData configured with GB UI Kit styling, button styles, input decorations, and typography.
This does not rely on legacy wrapper classes and can be used directly with MaterialApp.theme.
Implementation
ThemeData createGBTheme({
Color accentColor = DefaultColors.accent_accent_blue,
Color accentError = DefaultColors.accent_error_red,
Color accentErrorLight = DefaultColors.accent_error_red_light,
Color backgroundBase = DefaultColors.background_base,
Color backgroundContrast = DefaultColors.background_contrast,
Color backgroundDisabled = DefaultColors.background_disabled,
Color backgroundFocus = DefaultColors.background_focus,
Color primaryColor = DefaultColors.primaryPrimaryYellow,
Color textBase = DefaultColors.text_gray_base,
Color textBlack = DefaultColors.text_text_black,
Color textDisabled = DefaultColors.text_gray_disabled,
Color textWhite = DefaultColors.text_text_white,
TextTheme? textTheme,
BorderRadius? textFieldRadius,
double? textFieldBorderWidth,
BorderRadius? buttonsRadius,
InputDecorationThemeData? inputDecorationTheme,
ElevatedButtonThemeData? elevatedButtonTheme,
OutlinedButtonThemeData? outlinedButtonTheme,
SwitchThemeData? switchTheme,
ChipThemeData? chipTheme,
bool useMaterial3 = true,
}) {
final colorScheme = ColorScheme.fromSwatch().copyWith(
primary: primaryColor,
secondary: accentColor,
error: accentError,
surface: backgroundContrast,
onSurface: textBlack,
onPrimary: textWhite,
onSecondary: textWhite,
);
return ThemeData(
useMaterial3: useMaterial3,
primaryColor: primaryColor,
scaffoldBackgroundColor: backgroundBase,
cardColor: backgroundContrast,
disabledColor: backgroundDisabled,
focusColor: backgroundFocus,
colorScheme: colorScheme,
elevatedButtonTheme: createGBElevatedButtonTheme(
accentColor: accentColor,
backgroundDisabled: backgroundDisabled,
textWhite: textWhite,
buttonsRadius: buttonsRadius,
customTheme: elevatedButtonTheme,
),
outlinedButtonTheme: createGBOutlinedButtonTheme(
secondary: accentColor,
textBlack: textBlack,
textDisabled: textDisabled,
backgroundDisabled: backgroundDisabled,
borderRadius: buttonsRadius,
customTheme: outlinedButtonTheme,
),
switchTheme: createGBSwitchTheme(
accentColor: accentColor,
backgroundDisabled: backgroundDisabled,
customTheme: switchTheme,
),
chipTheme: createGBChipTheme(
textBlack: textBlack,
textBase: textBase,
customTheme: chipTheme,
),
inputDecorationTheme: createGBInputDecorationTheme(
accentColor: accentColor,
accentError: accentError,
accentErrorLight: accentErrorLight,
backgroundContrast: backgroundContrast,
backgroundDisabled: backgroundDisabled,
backgroundFocus: backgroundFocus,
textBase: textBase,
textFieldRadius: textFieldRadius,
textFieldBorderWidth: textFieldBorderWidth,
customTheme: inputDecorationTheme,
),
textTheme: createGBTextTheme(textTheme),
);
}