applyCustomTheme static method

ThemeData applyCustomTheme(
  1. ThemeData baseTheme,
  2. MkxThemeData customData
)

Applies custom theme data to a base theme

This method allows for partial theme customization by applying the non-null properties from customData to baseTheme.

Example:

final customTheme = MkxTheme.applyCustomTheme(
  MkxTheme.light,
  MkxThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple)),
);

More complex example:

// Create a branded theme with custom colors and input styling
final brandedTheme = MkxTheme.applyCustomTheme(
  MkxTheme.light,
  MkxThemeData(
    colorScheme: ColorScheme.fromSeed(
      seedColor: brandPrimaryColor,
      brightness: Brightness.light,
    ),
    inputDecorationTheme: InputDecorationTheme(
      filled: true,
      fillColor: brandLightColor,
      border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(12),
        borderSide: BorderSide(color: brandPrimaryColor.withOpacity(0.5)),
      ),
      focusedBorder: OutlineInputBorder(
        borderRadius: BorderRadius.circular(12),
        borderSide: BorderSide(color: brandPrimaryColor, width: 2),
      ),
    ),
  ),
);

Implementation

static ThemeData applyCustomTheme(
    ThemeData baseTheme, MkxThemeData customData) {
  return baseTheme.copyWith(
    colorScheme: customData.colorScheme ?? baseTheme.colorScheme,
    inputDecorationTheme:
        customData.inputDecorationTheme ?? baseTheme.inputDecorationTheme,
    elevatedButtonTheme:
        customData.elevatedButtonTheme ?? baseTheme.elevatedButtonTheme,
  );
}