generateCustomTheme static method

ThemeModel generateCustomTheme(
  1. Color primaryColor, {
  2. String? name,
})

Implementation

static ThemeModel generateCustomTheme(Color primaryColor, {String? name}) {
  // Create a MaterialColor swatch from the primary color
  final MaterialColor swatch = createMaterialColor(primaryColor);

  final brightness = estimateBrightness(primaryColor);
  final contrastColor =
      brightness == Brightness.dark ? Colors.white : Colors.black;

  return ThemeModel(
    type: ThemeType.custom,
    themeData: ThemeData(
      brightness: brightness,
      primarySwatch: swatch,
      primaryColor: primaryColor,
      appBarTheme: AppBarTheme(
        backgroundColor: primaryColor,
        foregroundColor: contrastColor,
      ),
      scaffoldBackgroundColor: brightness == Brightness.dark
          ? Color.lerp(Colors.black, primaryColor, 0.1)
          : Color.lerp(Colors.white, primaryColor, 0.05),
      colorScheme: ColorScheme.fromSwatch(
        primarySwatch: swatch,
        brightness: brightness,
      ),
      // Add more customizations here
    ),
  );
}