diff --git a/example/lib/example5_themes_playground/utils/generate_colorscheme_dart_code.dart b/example/lib/example5_themes_playground/utils/generate_colorscheme_dart_code.dart index 59b3ee29..0c31455d 100644 --- a/example/lib/example5_themes_playground/utils/generate_colorscheme_dart_code.dart +++ b/example/lib/example5_themes_playground/utils/generate_colorscheme_dart_code.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import '../../shared/const/app.dart'; import '../../shared/controllers/theme_controller.dart'; +import '../../shared/utils/color_string.dart'; import '../theme/flex_theme_dark.dart'; import '../theme/flex_theme_light.dart'; @@ -21,104 +22,104 @@ String generateColorSchemeDartCode( /// Requires Flutter 3.22.0 or later. const ColorScheme lightColorScheme = ColorScheme( brightness: ${lightScheme.brightness}, - primary: ${lightScheme.primary}, - onPrimary: ${lightScheme.onPrimary}, - primaryContainer: ${lightScheme.primaryContainer}, - onPrimaryContainer: ${lightScheme.onPrimaryContainer}, - primaryFixed: ${lightScheme.primaryFixed}, - primaryFixedDim: ${lightScheme.primaryFixedDim}, - onPrimaryFixed: ${lightScheme.onPrimaryFixed}, - onPrimaryFixedVariant: ${lightScheme.onPrimaryFixedVariant}, - secondary: ${lightScheme.secondary}, - onSecondary: ${lightScheme.onSecondary}, - secondaryContainer: ${lightScheme.secondaryContainer}, - onSecondaryContainer: ${lightScheme.onSecondaryContainer}, - secondaryFixed: ${lightScheme.secondaryFixed}, - secondaryFixedDim: ${lightScheme.secondaryFixedDim}, - onSecondaryFixed: ${lightScheme.onSecondaryFixed}, - onSecondaryFixedVariant: ${lightScheme.onSecondaryFixedVariant}, - tertiary: ${lightScheme.tertiary}, - onTertiary: ${lightScheme.onTertiary}, - tertiaryContainer: ${lightScheme.tertiaryContainer}, - onTertiaryContainer: ${lightScheme.onTertiaryContainer}, - tertiaryFixed: ${lightScheme.tertiaryFixed}, - tertiaryFixedDim: ${lightScheme.tertiaryFixedDim}, - onTertiaryFixed: ${lightScheme.onTertiaryFixed}, - onTertiaryFixedVariant: ${lightScheme.onTertiaryFixedVariant}, - error: ${lightScheme.error}, - onError: ${lightScheme.onError}, - errorContainer: ${lightScheme.errorContainer}, - onErrorContainer: ${lightScheme.onErrorContainer}, - surface: ${lightScheme.surface}, - onSurface: ${lightScheme.onSurface}, - surfaceDim: ${lightScheme.surfaceDim}, - surfaceBright: ${lightScheme.surfaceBright}, - surfaceContainerLowest: ${lightScheme.surfaceContainerLowest}, - surfaceContainerLow: ${lightScheme.surfaceContainerLow}, - surfaceContainer: ${lightScheme.surfaceContainer}, - surfaceContainerHigh: ${lightScheme.surfaceContainerHigh}, - surfaceContainerHighest: ${lightScheme.surfaceContainerHighest}, - onSurfaceVariant: ${lightScheme.onSurfaceVariant}, - outline: ${lightScheme.outline}, - outlineVariant: ${lightScheme.outlineVariant}, - shadow: ${lightScheme.shadow}, - scrim: ${lightScheme.scrim}, - inverseSurface: ${lightScheme.inverseSurface}, - onInverseSurface: ${lightScheme.onInverseSurface}, - inversePrimary: ${lightScheme.inversePrimary}, - surfaceTint: ${lightScheme.surfaceTint}, + primary: ${lightScheme.primary.toColorString()}, + onPrimary: ${lightScheme.onPrimary.toColorString()}, + primaryContainer: ${lightScheme.primaryContainer.toColorString()}, + onPrimaryContainer: ${lightScheme.onPrimaryContainer.toColorString()}, + primaryFixed: ${lightScheme.primaryFixed.toColorString()}, + primaryFixedDim: ${lightScheme.primaryFixedDim.toColorString()}, + onPrimaryFixed: ${lightScheme.onPrimaryFixed.toColorString()}, + onPrimaryFixedVariant: ${lightScheme.onPrimaryFixedVariant.toColorString()}, + secondary: ${lightScheme.secondary.toColorString()}, + onSecondary: ${lightScheme.onSecondary.toColorString()}, + secondaryContainer: ${lightScheme.secondaryContainer.toColorString()}, + onSecondaryContainer: ${lightScheme.onSecondaryContainer.toColorString()}, + secondaryFixed: ${lightScheme.secondaryFixed.toColorString()}, + secondaryFixedDim: ${lightScheme.secondaryFixedDim.toColorString()}, + onSecondaryFixed: ${lightScheme.onSecondaryFixed.toColorString()}, + onSecondaryFixedVariant: ${lightScheme.onSecondaryFixedVariant.toColorString()}, + tertiary: ${lightScheme.tertiary.toColorString()}, + onTertiary: ${lightScheme.onTertiary.toColorString()}, + tertiaryContainer: ${lightScheme.tertiaryContainer.toColorString()}, + onTertiaryContainer: ${lightScheme.onTertiaryContainer.toColorString()}, + tertiaryFixed: ${lightScheme.tertiaryFixed.toColorString()}, + tertiaryFixedDim: ${lightScheme.tertiaryFixedDim.toColorString()}, + onTertiaryFixed: ${lightScheme.onTertiaryFixed.toColorString()}, + onTertiaryFixedVariant: ${lightScheme.onTertiaryFixedVariant.toColorString()}, + error: ${lightScheme.error.toColorString()}, + onError: ${lightScheme.onError.toColorString()}, + errorContainer: ${lightScheme.errorContainer.toColorString()}, + onErrorContainer: ${lightScheme.onErrorContainer.toColorString()}, + surface: ${lightScheme.surface.toColorString()}, + onSurface: ${lightScheme.onSurface.toColorString()}, + surfaceDim: ${lightScheme.surfaceDim.toColorString()}, + surfaceBright: ${lightScheme.surfaceBright.toColorString()}, + surfaceContainerLowest: ${lightScheme.surfaceContainerLowest.toColorString()}, + surfaceContainerLow: ${lightScheme.surfaceContainerLow.toColorString()}, + surfaceContainer: ${lightScheme.surfaceContainer.toColorString()}, + surfaceContainerHigh: ${lightScheme.surfaceContainerHigh.toColorString()}, + surfaceContainerHighest: ${lightScheme.surfaceContainerHighest.toColorString()}, + onSurfaceVariant: ${lightScheme.onSurfaceVariant.toColorString()}, + outline: ${lightScheme.outline.toColorString()}, + outlineVariant: ${lightScheme.outlineVariant.toColorString()}, + shadow: ${lightScheme.shadow.toColorString()}, + scrim: ${lightScheme.scrim.toColorString()}, + inverseSurface: ${lightScheme.inverseSurface.toColorString()}, + onInverseSurface: ${lightScheme.onInverseSurface.toColorString()}, + inversePrimary: ${lightScheme.inversePrimary.toColorString()}, + surfaceTint: ${lightScheme.surfaceTint.toColorString()}, ); /// Dark [ColorScheme] made with FlexColorScheme v${App.version}. /// Requires Flutter 3.22.0 or later. const ColorScheme darkColorScheme = ColorScheme( brightness: ${darkScheme.brightness}, - primary: ${darkScheme.primary}, - onPrimary: ${darkScheme.onPrimary}, - primaryContainer: ${darkScheme.primaryContainer}, - onPrimaryContainer: ${darkScheme.onPrimaryContainer}, - primaryFixed: ${darkScheme.primaryFixed}, - primaryFixedDim: ${darkScheme.primaryFixedDim}, - onPrimaryFixed: ${darkScheme.onPrimaryFixed}, - onPrimaryFixedVariant: ${darkScheme.onPrimaryFixedVariant}, - secondary: ${darkScheme.secondary}, - onSecondary: ${darkScheme.onSecondary}, - secondaryContainer: ${darkScheme.secondaryContainer}, - onSecondaryContainer: ${darkScheme.onSecondaryContainer}, - secondaryFixed: ${darkScheme.secondaryFixed}, - secondaryFixedDim: ${darkScheme.secondaryFixedDim}, - onSecondaryFixed: ${darkScheme.onSecondaryFixed}, - onSecondaryFixedVariant: ${darkScheme.onSecondaryFixedVariant}, - tertiary: ${darkScheme.tertiary}, - onTertiary: ${darkScheme.onTertiary}, - tertiaryContainer: ${darkScheme.tertiaryContainer}, - onTertiaryContainer: ${darkScheme.onTertiaryContainer}, - tertiaryFixed: ${darkScheme.tertiaryFixed}, - tertiaryFixedDim: ${darkScheme.tertiaryFixedDim}, - onTertiaryFixed: ${darkScheme.onTertiaryFixed}, - onTertiaryFixedVariant: ${darkScheme.onTertiaryFixedVariant}, - error: ${darkScheme.error}, - onError: ${darkScheme.onError}, - errorContainer: ${darkScheme.errorContainer}, - onErrorContainer: ${darkScheme.onErrorContainer}, - surface: ${darkScheme.surface}, - onSurface: ${darkScheme.onSurface}, - surfaceDim: ${darkScheme.surfaceDim}, - surfaceBright: ${darkScheme.surfaceBright}, - surfaceContainerLowest: ${darkScheme.surfaceContainerLowest}, - surfaceContainerLow: ${darkScheme.surfaceContainerLow}, - surfaceContainer: ${darkScheme.surfaceContainer}, - surfaceContainerHigh: ${darkScheme.surfaceContainerHigh}, - surfaceContainerHighest: ${darkScheme.surfaceContainerHighest}, - onSurfaceVariant: ${darkScheme.onSurfaceVariant}, - outline: ${darkScheme.outline}, - outlineVariant: ${darkScheme.outlineVariant}, - shadow: ${darkScheme.shadow}, - scrim: ${darkScheme.scrim}, - inverseSurface: ${darkScheme.inverseSurface}, - onInverseSurface: ${darkScheme.onInverseSurface}, - inversePrimary: ${darkScheme.inversePrimary}, - surfaceTint: ${darkScheme.surfaceTint}, + primary: ${darkScheme.primary.toColorString()}, + onPrimary: ${darkScheme.onPrimary.toColorString()}, + primaryContainer: ${darkScheme.primaryContainer.toColorString()}, + onPrimaryContainer: ${darkScheme.onPrimaryContainer.toColorString()}, + primaryFixed: ${darkScheme.primaryFixed.toColorString()}, + primaryFixedDim: ${darkScheme.primaryFixedDim.toColorString()}, + onPrimaryFixed: ${darkScheme.onPrimaryFixed.toColorString()}, + onPrimaryFixedVariant: ${darkScheme.onPrimaryFixedVariant.toColorString()}, + secondary: ${darkScheme.secondary.toColorString()}, + onSecondary: ${darkScheme.onSecondary.toColorString()}, + secondaryContainer: ${darkScheme.secondaryContainer.toColorString()}, + onSecondaryContainer: ${darkScheme.onSecondaryContainer.toColorString()}, + secondaryFixed: ${darkScheme.secondaryFixed.toColorString()}, + secondaryFixedDim: ${darkScheme.secondaryFixedDim.toColorString()}, + onSecondaryFixed: ${darkScheme.onSecondaryFixed.toColorString()}, + onSecondaryFixedVariant: ${darkScheme.onSecondaryFixedVariant.toColorString()}, + tertiary: ${darkScheme.tertiary.toColorString()}, + onTertiary: ${darkScheme.onTertiary.toColorString()}, + tertiaryContainer: ${darkScheme.tertiaryContainer.toColorString()}, + onTertiaryContainer: ${darkScheme.onTertiaryContainer.toColorString()}, + tertiaryFixed: ${darkScheme.tertiaryFixed.toColorString()}, + tertiaryFixedDim: ${darkScheme.tertiaryFixedDim.toColorString()}, + onTertiaryFixed: ${darkScheme.onTertiaryFixed.toColorString()}, + onTertiaryFixedVariant: ${darkScheme.onTertiaryFixedVariant.toColorString()}, + error: ${darkScheme.error.toColorString()}, + onError: ${darkScheme.onError.toColorString()}, + errorContainer: ${darkScheme.errorContainer.toColorString()}, + onErrorContainer: ${darkScheme.onErrorContainer.toColorString()}, + surface: ${darkScheme.surface.toColorString()}, + onSurface: ${darkScheme.onSurface.toColorString()}, + surfaceDim: ${darkScheme.surfaceDim.toColorString()}, + surfaceBright: ${darkScheme.surfaceBright.toColorString()}, + surfaceContainerLowest: ${darkScheme.surfaceContainerLowest.toColorString()}, + surfaceContainerLow: ${darkScheme.surfaceContainerLow.toColorString()}, + surfaceContainer: ${darkScheme.surfaceContainer.toColorString()}, + surfaceContainerHigh: ${darkScheme.surfaceContainerHigh.toColorString()}, + surfaceContainerHighest: ${darkScheme.surfaceContainerHighest.toColorString()}, + onSurfaceVariant: ${darkScheme.onSurfaceVariant.toColorString()}, + outline: ${darkScheme.outline.toColorString()}, + outlineVariant: ${darkScheme.outlineVariant.toColorString()}, + shadow: ${darkScheme.shadow.toColorString()}, + scrim: ${darkScheme.scrim.toColorString()}, + inverseSurface: ${darkScheme.inverseSurface.toColorString()}, + onInverseSurface: ${darkScheme.onInverseSurface.toColorString()}, + inversePrimary: ${darkScheme.inversePrimary.toColorString()}, + surfaceTint: ${darkScheme.surfaceTint.toColorString()}, ); '''; return code; diff --git a/example/lib/example5_themes_playground/utils/generate_theme_dart_code.dart b/example/lib/example5_themes_playground/utils/generate_theme_dart_code.dart index 220bb4e8..0f7a2459 100644 --- a/example/lib/example5_themes_playground/utils/generate_theme_dart_code.dart +++ b/example/lib/example5_themes_playground/utils/generate_theme_dart_code.dart @@ -6,6 +6,7 @@ import '../../shared/const/app.dart'; import '../../shared/const/app_color.dart'; import '../../shared/controllers/theme_controller.dart'; import '../../shared/model/adaptive_response.dart'; +import '../../shared/utils/color_string.dart'; import '../theme/theme_values.dart'; /// A function that returns the FlexColorScheme Dart and Flutter setup @@ -55,97 +56,97 @@ String generateThemeDartCode(ThemeController controller) { String lightScheme = useBuiltIn ? ' scheme: ${FlexScheme.values[flexScheme]},\n' : ' colors: const FlexSchemeColor(\n' - ' primary: ${scheme.light.primary},\n' - ' primaryContainer: ${scheme.light.primaryContainer},\n' - ' primaryLightRef: ${scheme.light.primaryLightRef},\n' - ' secondary: ${scheme.light.secondary},\n' - ' secondaryContainer: ${scheme.light.secondaryContainer},\n' - ' secondaryLightRef: ${scheme.light.secondaryLightRef},\n' - ' tertiary: ${scheme.light.tertiary},\n' - ' tertiaryContainer: ${scheme.light.tertiaryContainer},\n' - ' tertiaryLightRef: ${scheme.light.tertiaryLightRef},\n' - ' appBarColor: ${scheme.light.appBarColor},\n' - ' error: ${scheme.light.error},\n' - ' errorContainer: ${scheme.light.errorContainer},\n' + ' primary: ${scheme.light.primary.toColorString()},\n' + ' primaryContainer: ${scheme.light.primaryContainer.toColorString()},\n' + ' primaryLightRef: ${scheme.light.primaryLightRef.toColorString()},\n' + ' secondary: ${scheme.light.secondary.toColorString()},\n' + ' secondaryContainer: ${scheme.light.secondaryContainer.toColorString()},\n' + ' secondaryLightRef: ${scheme.light.secondaryLightRef.toColorString()},\n' + ' tertiary: ${scheme.light.tertiary.toColorString()},\n' + ' tertiaryContainer: ${scheme.light.tertiaryContainer.toColorString()},\n' + ' tertiaryLightRef: ${scheme.light.tertiaryLightRef.toColorString()},\n' + ' appBarColor: ${scheme.light.appBarColor.toColorString()},\n' + ' error: ${scheme.light.error.toColorString()},\n' + ' errorContainer: ${scheme.light.errorContainer.toColorString()},\n' ' ),\n'; if (useCustom) { lightScheme = ' colors: const FlexSchemeColor( // Custom\n' - ' primary: ${controller.customPrimaryLight},\n' - ' primaryContainer: ${controller.customPrimaryContainerLight},\n' - ' primaryLightRef: ${controller.customPrimaryLightRef},\n' - ' secondary: ${controller.customSecondaryLight},\n' - ' secondaryContainer: ${controller.customSecondaryContainerLight},\n' - ' secondaryLightRef: ${controller.customSecondaryLightRef},\n' - ' tertiary: ${controller.customTertiaryLight},\n' - ' tertiaryContainer: ${controller.customTertiaryContainerLight},\n' - ' tertiaryLightRef: ${controller.customTertiaryLightRef},\n' - ' appBarColor: ${scheme.light.appBarColor},\n' - ' error: ${controller.customErrorLight},\n' - ' errorContainer: ${controller.customErrorContainerLight},\n' + ' primary: ${controller.customPrimaryLight.toColorString()},\n' + ' primaryContainer: ${controller.customPrimaryContainerLight.toColorString()},\n' + ' primaryLightRef: ${controller.customPrimaryLightRef.toColorString()},\n' + ' secondary: ${controller.customSecondaryLight.toColorString()},\n' + ' secondaryContainer: ${controller.customSecondaryContainerLight.toColorString()},\n' + ' secondaryLightRef: ${controller.customSecondaryLightRef.toColorString()},\n' + ' tertiary: ${controller.customTertiaryLight.toColorString()},\n' + ' tertiaryContainer: ${controller.customTertiaryContainerLight.toColorString()},\n' + ' tertiaryLightRef: ${controller.customTertiaryLightRef.toColorString()},\n' + ' appBarColor: ${scheme.light.appBarColor.toColorString()},\n' + ' error: ${controller.customErrorLight.toColorString()},\n' + ' errorContainer: ${controller.customErrorContainerLight.toColorString()},\n' ' ),\n'; } String darkScheme = useBuiltIn ? ' scheme: ${FlexScheme.values[flexScheme]},\n' : ' colors: const FlexSchemeColor(\n' - ' primary: ${scheme.dark.primary},\n' - ' primaryContainer: ${scheme.dark.primaryContainer},\n' - ' primaryLightRef: ${scheme.light.primaryLightRef},\n' - ' secondary: ${scheme.dark.secondary},\n' - ' secondaryContainer: ${scheme.dark.secondaryContainer},\n' - ' secondaryLightRef: ${scheme.light.secondaryLightRef},\n' - ' tertiary: ${scheme.dark.tertiary},\n' - ' tertiaryContainer: ${scheme.dark.tertiaryContainer},\n' - ' tertiaryLightRef: ${scheme.light.tertiaryLightRef},\n' - ' appBarColor: ${scheme.dark.appBarColor},\n' - ' error: ${scheme.dark.error},\n' - ' errorContainer: ${scheme.dark.errorContainer},\n' + ' primary: ${scheme.dark.primary.toColorString()},\n' + ' primaryContainer: ${scheme.dark.primaryContainer.toColorString()},\n' + ' primaryLightRef: ${scheme.light.primaryLightRef.toColorString()},\n' + ' secondary: ${scheme.dark.secondary.toColorString()},\n' + ' secondaryContainer: ${scheme.dark.secondaryContainer.toColorString()},\n' + ' secondaryLightRef: ${scheme.light.secondaryLightRef.toColorString()},\n' + ' tertiary: ${scheme.dark.tertiary.toColorString()},\n' + ' tertiaryContainer: ${scheme.dark.tertiaryContainer.toColorString()},\n' + ' tertiaryLightRef: ${scheme.light.tertiaryLightRef.toColorString()},\n' + ' appBarColor: ${scheme.dark.appBarColor.toColorString()},\n' + ' error: ${scheme.dark.error.toColorString()},\n' + ' errorContainer: ${scheme.dark.errorContainer.toColorString()},\n' ' ),\n'; if (useCustom) { darkScheme = ' colors: const FlexSchemeColor( // Custom\n' - ' primary: ${controller.customPrimaryDark},\n' - ' primaryContainer: ${controller.customPrimaryContainerDark},\n' - ' primaryLightRef: ${controller.customPrimaryDarkRef},\n' - ' secondary: ${controller.customSecondaryDark},\n' - ' secondaryContainer: ${controller.customSecondaryContainerDark},\n' - ' secondaryLightRef: ${controller.customSecondaryDarkRef},\n' - ' tertiary: ${controller.customTertiaryDark},\n' - ' tertiaryContainer: ${controller.customTertiaryContainerDark},\n' - ' tertiaryLightRef: ${controller.customTertiaryDarkRef},\n' - ' appBarColor: ${scheme.light.appBarColor},\n' - ' error: ${controller.customErrorDark},\n' - ' errorContainer: ${controller.customErrorContainerDark},\n' + ' primary: ${controller.customPrimaryDark.toColorString()},\n' + ' primaryContainer: ${controller.customPrimaryContainerDark.toColorString()},\n' + ' primaryLightRef: ${controller.customPrimaryDarkRef.toColorString()},\n' + ' secondary: ${controller.customSecondaryDark.toColorString()},\n' + ' secondaryContainer: ${controller.customSecondaryContainerDark.toColorString()},\n' + ' secondaryLightRef: ${controller.customSecondaryDarkRef.toColorString()},\n' + ' tertiary: ${controller.customTertiaryDark.toColorString()},\n' + ' tertiaryContainer: ${controller.customTertiaryContainerDark.toColorString()},\n' + ' tertiaryLightRef: ${controller.customTertiaryDarkRef.toColorString()},\n' + ' appBarColor: ${scheme.light.appBarColor.toColorString()},\n' + ' error: ${controller.customErrorDark.toColorString()},\n' + ' errorContainer: ${controller.customErrorContainerDark.toColorString()},\n' ' ),\n'; } if (controller.useToDarkMethod && !useBuiltIn && !controller.useKeyColors) { if (useCustom) { darkScheme = ' colors: const FlexSchemeColor(\n' - ' primary: ${scheme.dark.primary},\n' - ' primaryContainer: ${scheme.dark.primaryContainer},\n' - ' primaryLightRef: ${scheme.light.primaryLightRef},\n' - ' secondary: ${scheme.dark.secondary},\n' - ' secondaryContainer: ${scheme.dark.secondaryContainer},\n' - ' secondaryLightRef: ${scheme.light.secondaryLightRef},\n' - ' tertiary: ${scheme.dark.tertiary},\n' - ' tertiaryContainer: ${scheme.dark.tertiaryContainer},\n' - ' tertiaryLightRef: ${scheme.light.tertiaryLightRef},\n' - ' appBarColor: ${scheme.dark.appBarColor},\n' - ' error: ${scheme.dark.error},\n' - ' errorContainer: ${scheme.dark.errorContainer},\n' + ' primary: ${scheme.dark.primary.toColorString()},\n' + ' primaryContainer: ${scheme.dark.primaryContainer.toColorString()},\n' + ' primaryLightRef: ${scheme.light.primaryLightRef.toColorString()},\n' + ' secondary: ${scheme.dark.secondary.toColorString()},\n' + ' secondaryContainer: ${scheme.dark.secondaryContainer.toColorString()},\n' + ' secondaryLightRef: ${scheme.light.secondaryLightRef.toColorString()},\n' + ' tertiary: ${scheme.dark.tertiary.toColorString()},\n' + ' tertiaryContainer: ${scheme.dark.tertiaryContainer.toColorString()},\n' + ' tertiaryLightRef: ${scheme.light.tertiaryLightRef.toColorString()},\n' + ' appBarColor: ${scheme.dark.appBarColor.toColorString()},\n' + ' error: ${scheme.dark.error.toColorString()},\n' + ' errorContainer: ${scheme.dark.errorContainer.toColorString()},\n' ' ).defaultError.toDark(${controller.toDarkMethodLevel}, ${controller.toDarkSwapPrimaryAndContainer}),\n'; } else { darkScheme = ' colors: const FlexSchemeColor(\n' - ' primary: ${scheme.light.primary},\n' - ' primaryContainer: ${scheme.light.primaryContainer},\n' - ' primaryLightRef: ${scheme.light.primaryLightRef},\n' - ' secondary: ${scheme.light.secondary},\n' - ' secondaryContainer: ${scheme.light.secondaryContainer},\n' - ' secondaryLightRef: ${scheme.light.secondaryLightRef},\n' - ' tertiary: ${scheme.light.tertiary},\n' - ' tertiaryContainer: ${scheme.light.tertiaryContainer},\n' - ' tertiaryLightRef: ${scheme.light.tertiaryLightRef},\n' - ' appBarColor: ${scheme.light.appBarColor},\n' - ' error: ${scheme.light.error},\n' - ' errorContainer: ${scheme.light.errorContainer},\n' + ' primary: ${scheme.light.primary.toColorString()},\n' + ' primaryContainer: ${scheme.light.primaryContainer.toColorString()},\n' + ' primaryLightRef: ${scheme.light.primaryLightRef.toColorString()},\n' + ' secondary: ${scheme.light.secondary.toColorString()},\n' + ' secondaryContainer: ${scheme.light.secondaryContainer.toColorString()},\n' + ' secondaryLightRef: ${scheme.light.secondaryLightRef.toColorString()},\n' + ' tertiary: ${scheme.light.tertiary.toColorString()},\n' + ' tertiaryContainer: ${scheme.light.tertiaryContainer.toColorString()},\n' + ' tertiaryLightRef: ${scheme.light.tertiaryLightRef.toColorString()},\n' + ' appBarColor: ${scheme.light.appBarColor.toColorString()},\n' + ' error: ${scheme.light.error.toColorString()},\n' + ' errorContainer: ${scheme.light.errorContainer.toColorString()},\n' ' ).defaultError.toDark(${controller.toDarkMethodLevel}, ${controller.toDarkSwapPrimaryAndContainer}),\n'; } } @@ -257,10 +258,10 @@ String generateThemeDartCode(ThemeController controller) { ? ' useMaterial3ErrorColors: ${controller.useM3ErrorColors},\n' : ''; final String tintLightColor = controller.surfaceTintLight != null - ? ' surfaceTint: const ${controller.surfaceTintLight},\n' + ? ' surfaceTint: const ${controller.surfaceTintLight.toColorString()},\n' : ''; final String tintDarkColor = controller.surfaceTintDark != null - ? ' surfaceTint: const ${controller.surfaceTintDark},\n' + ? ' surfaceTint: const ${controller.surfaceTintDark.toColorString()},\n' : ''; // Do we apply Cupertino to all components? final String applyToAllCupertino = controller.applyThemeToAllCupertino @@ -1161,7 +1162,7 @@ String generateThemeDartCode(ThemeController controller) { ? ' tabBarIndicatorTopRadius: ${controller.tabBarIndicatorTopRadius},\n' : ''; final String tabBarDividerColor = controller.tabBarDividerColor != null - ? ' tabBarDividerColor: ${controller.tabBarDividerColor},\n' + ? ' tabBarDividerColor: ${controller.tabBarDividerColor.toColorString()},\n' : ''; final String tabBarTabAlignment = controller.tabBarTabAlignment != null ? ' tabBarTabAlignment: ${controller.tabBarTabAlignment},\n' @@ -1328,7 +1329,7 @@ String generateThemeDartCode(ThemeController controller) { ? ' menuBarElevation: ${controller.menuBarElevation!.toStringAsFixed(1)},\n' : ''; final String menuBarShadowColor = controller.menuBarShadowColor != null - ? ' menuBarShadowColor: ${controller.menuBarShadowColor},\n' + ? ' menuBarShadowColor: ${controller.menuBarShadowColor.toColorString()},\n' : ''; // final String menuItemBackgroundSchemeColor = controller diff --git a/example/lib/shared/utils/color_string.dart b/example/lib/shared/utils/color_string.dart new file mode 100644 index 00000000..076a83ca --- /dev/null +++ b/example/lib/shared/utils/color_string.dart @@ -0,0 +1,15 @@ +import 'dart:ui'; + +/// An extension on [Color] to return the color values as a string +/// with format Color(0x12345678). +extension ColorStringClass on Color? { + /// Returns the color values as a string with format Color(0x12345678). + String toColorString() { + if (this == null) { + return 'Color(0x00000000)'; + } else { + // ignore: lines_longer_than_80_chars + return 'Color(0x${this!.value.toRadixString(16).padLeft(8, '0').toUpperCase()})'; + } + } +}