Last active
June 19, 2026 07:34
-
-
Save deminearchiver/4c43c6b015d3614dfaaf597102ff441f to your computer and use it in GitHub Desktop.
Flutter lazy color scheme feat. libmonet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/foundation.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:libmonet/libmonet.dart'; | |
| extension DynamicSchemeExtension on DynamicScheme { | |
| ColorScheme toColorScheme({required bool lazy}) => lazy | |
| ? _LazyColorScheme(this) | |
| : ColorScheme( | |
| brightness: isDark ? .dark : .light, | |
| // ignore: deprecated_member_use | |
| background: Color(background), | |
| // ignore: deprecated_member_use | |
| onBackground: Color(onBackground), | |
| surface: Color(surface), | |
| surfaceDim: Color(surfaceDim), | |
| surfaceBright: Color(surfaceBright), | |
| surfaceContainerLowest: Color(surfaceContainerLowest), | |
| surfaceContainerLow: Color(surfaceContainerLow), | |
| surfaceContainer: Color(surfaceContainer), | |
| surfaceContainerHigh: Color(surfaceContainerHigh), | |
| surfaceContainerHighest: Color(surfaceContainerHighest), | |
| onSurface: Color(onSurface), | |
| // ignore: deprecated_member_use | |
| surfaceVariant: Color(surfaceVariant), | |
| onSurfaceVariant: Color(onSurfaceVariant), | |
| outline: Color(outline), | |
| outlineVariant: Color(outlineVariant), | |
| inverseSurface: Color(inverseSurface), | |
| onInverseSurface: Color(inverseOnSurface), | |
| shadow: Color(shadow), | |
| scrim: Color(scrim), | |
| surfaceTint: Color(surfaceTint), | |
| primary: Color(primary), | |
| onPrimary: Color(onPrimary), | |
| primaryContainer: Color(primaryContainer), | |
| onPrimaryContainer: Color(onPrimaryContainer), | |
| primaryFixed: Color(primaryFixed), | |
| primaryFixedDim: Color(primaryFixedDim), | |
| onPrimaryFixed: Color(onPrimaryFixed), | |
| onPrimaryFixedVariant: Color(onPrimaryFixedVariant), | |
| inversePrimary: Color(inversePrimary), | |
| secondary: Color(secondary), | |
| onSecondary: Color(onSecondary), | |
| secondaryContainer: Color(secondaryContainer), | |
| onSecondaryContainer: Color(onSecondaryContainer), | |
| secondaryFixed: Color(secondaryFixed), | |
| secondaryFixedDim: Color(secondaryFixedDim), | |
| onSecondaryFixed: Color(onSecondaryFixed), | |
| onSecondaryFixedVariant: Color(onSecondaryFixedVariant), | |
| tertiary: Color(tertiary), | |
| onTertiary: Color(onTertiary), | |
| tertiaryContainer: Color(tertiaryContainer), | |
| onTertiaryContainer: Color(onTertiaryContainer), | |
| tertiaryFixed: Color(tertiaryFixed), | |
| tertiaryFixedDim: Color(tertiaryFixedDim), | |
| onTertiaryFixed: Color(onTertiaryFixed), | |
| onTertiaryFixedVariant: Color(onTertiaryFixedVariant), | |
| error: Color(error), | |
| onError: Color(onError), | |
| errorContainer: Color(errorContainer), | |
| onErrorContainer: Color(onErrorContainer), | |
| ); | |
| } | |
| // ignore: must_be_immutable | |
| final class _LazyColorScheme with Diagnosticable implements ColorScheme { | |
| _LazyColorScheme( | |
| this._scheme, { | |
| this._brightness, | |
| this._background, | |
| this._onBackground, | |
| this._surface, | |
| this._surfaceDim, | |
| this._surfaceBright, | |
| this._surfaceContainerLowest, | |
| this._surfaceContainerLow, | |
| this._surfaceContainer, | |
| this._surfaceContainerHigh, | |
| this._surfaceContainerHighest, | |
| this._onSurface, | |
| this._surfaceVariant, | |
| this._onSurfaceVariant, | |
| this._outline, | |
| this._outlineVariant, | |
| this._inverseSurface, | |
| this._onInverseSurface, | |
| this._shadow, | |
| this._scrim, | |
| this._surfaceTint, | |
| this._primary, | |
| this._onPrimary, | |
| this._primaryContainer, | |
| this._onPrimaryContainer, | |
| this._primaryFixed, | |
| this._primaryFixedDim, | |
| this._onPrimaryFixed, | |
| this._onPrimaryFixedVariant, | |
| this._inversePrimary, | |
| this._secondary, | |
| this._onSecondary, | |
| this._secondaryContainer, | |
| this._onSecondaryContainer, | |
| this._secondaryFixed, | |
| this._secondaryFixedDim, | |
| this._onSecondaryFixed, | |
| this._onSecondaryFixedVariant, | |
| this._tertiary, | |
| this._onTertiary, | |
| this._tertiaryContainer, | |
| this._onTertiaryContainer, | |
| this._tertiaryFixed, | |
| this._tertiaryFixedDim, | |
| this._onTertiaryFixed, | |
| this._onTertiaryFixedVariant, | |
| this._error, | |
| this._onError, | |
| this._errorContainer, | |
| this._onErrorContainer, | |
| }); | |
| final DynamicScheme _scheme; | |
| Brightness? _brightness; | |
| Color? _background; | |
| Color? _onBackground; | |
| Color? _surface; | |
| Color? _surfaceDim; | |
| Color? _surfaceBright; | |
| Color? _surfaceContainerLowest; | |
| Color? _surfaceContainerLow; | |
| Color? _surfaceContainer; | |
| Color? _surfaceContainerHigh; | |
| Color? _surfaceContainerHighest; | |
| Color? _onSurface; | |
| Color? _surfaceVariant; | |
| Color? _onSurfaceVariant; | |
| Color? _outline; | |
| Color? _outlineVariant; | |
| Color? _inverseSurface; | |
| Color? _onInverseSurface; | |
| Color? _shadow; | |
| Color? _scrim; | |
| Color? _surfaceTint; | |
| Color? _primary; | |
| Color? _onPrimary; | |
| Color? _primaryContainer; | |
| Color? _onPrimaryContainer; | |
| Color? _primaryFixed; | |
| Color? _primaryFixedDim; | |
| Color? _onPrimaryFixed; | |
| Color? _onPrimaryFixedVariant; | |
| Color? _inversePrimary; | |
| Color? _secondary; | |
| Color? _onSecondary; | |
| Color? _secondaryContainer; | |
| Color? _onSecondaryContainer; | |
| Color? _secondaryFixed; | |
| Color? _secondaryFixedDim; | |
| Color? _onSecondaryFixed; | |
| Color? _onSecondaryFixedVariant; | |
| Color? _tertiary; | |
| Color? _onTertiary; | |
| Color? _tertiaryContainer; | |
| Color? _onTertiaryContainer; | |
| Color? _tertiaryFixed; | |
| Color? _tertiaryFixedDim; | |
| Color? _onTertiaryFixed; | |
| Color? _onTertiaryFixedVariant; | |
| Color? _error; | |
| Color? _onError; | |
| Color? _errorContainer; | |
| Color? _onErrorContainer; | |
| @override | |
| Brightness get brightness => | |
| _brightness ??= (_scheme.isDark ? .dark : .light); | |
| @override | |
| Color get background => _background ??= Color(_scheme.background); | |
| @override | |
| Color get onBackground => _onBackground ??= Color(_scheme.onBackground); | |
| @override | |
| Color get surface => _surface ??= Color(_scheme.surface); | |
| @override | |
| Color get surfaceDim => _surfaceDim ??= Color(_scheme.surfaceDim); | |
| @override | |
| Color get surfaceBright => _surfaceBright ??= Color(_scheme.surfaceBright); | |
| @override | |
| Color get surfaceContainerLowest => | |
| _surfaceContainerLowest ??= Color(_scheme.surfaceContainerLowest); | |
| @override | |
| Color get surfaceContainerLow => | |
| _surfaceContainerLow ??= Color(_scheme.surfaceContainerLow); | |
| @override | |
| Color get surfaceContainer => | |
| _surfaceContainer ??= Color(_scheme.surfaceContainer); | |
| @override | |
| Color get surfaceContainerHigh => | |
| _surfaceContainerHigh ??= Color(_scheme.surfaceContainerHigh); | |
| @override | |
| Color get surfaceContainerHighest => | |
| _surfaceContainerHighest ??= Color(_scheme.surfaceContainerHighest); | |
| @override | |
| Color get onSurface => _onSurface ??= Color(_scheme.onSurface); | |
| @override | |
| Color get surfaceVariant => _surfaceVariant ??= Color(_scheme.surfaceVariant); | |
| @override | |
| Color get onSurfaceVariant => | |
| _onSurfaceVariant ??= Color(_scheme.onSurfaceVariant); | |
| @override | |
| Color get outline => _outline ??= Color(_scheme.outline); | |
| @override | |
| Color get outlineVariant => _outlineVariant ??= Color(_scheme.outlineVariant); | |
| @override | |
| Color get inverseSurface => _inverseSurface ??= Color(_scheme.inverseSurface); | |
| @override | |
| Color get onInverseSurface => | |
| _onInverseSurface ??= Color(_scheme.inverseOnSurface); | |
| @override | |
| Color get shadow => _shadow ??= Color(_scheme.shadow); | |
| @override | |
| Color get scrim => _scrim ??= Color(_scheme.scrim); | |
| @override | |
| Color get surfaceTint => _surfaceTint ??= Color(_scheme.surfaceTint); | |
| @override | |
| Color get primary => _primary ??= Color(_scheme.primary); | |
| @override | |
| Color get onPrimary => _onPrimary ??= Color(_scheme.onPrimary); | |
| @override | |
| Color get primaryContainer => | |
| _primaryContainer ??= Color(_scheme.primaryContainer); | |
| @override | |
| Color get onPrimaryContainer => | |
| _onPrimaryContainer ??= Color(_scheme.onPrimaryContainer); | |
| @override | |
| Color get primaryFixed => _primaryFixed ??= Color(_scheme.primaryFixed); | |
| @override | |
| Color get primaryFixedDim => | |
| _primaryFixedDim ??= Color(_scheme.primaryFixedDim); | |
| @override | |
| Color get onPrimaryFixed => _onPrimaryFixed ??= Color(_scheme.onPrimaryFixed); | |
| @override | |
| Color get onPrimaryFixedVariant => | |
| _onPrimaryFixedVariant ??= Color(_scheme.onPrimaryFixedVariant); | |
| @override | |
| Color get inversePrimary => _inversePrimary ??= Color(_scheme.inversePrimary); | |
| @override | |
| Color get secondary => _secondary ??= Color(_scheme.secondary); | |
| @override | |
| Color get onSecondary => _onSecondary ??= Color(_scheme.onSecondary); | |
| @override | |
| Color get secondaryContainer => | |
| _secondaryContainer ??= Color(_scheme.secondaryContainer); | |
| @override | |
| Color get onSecondaryContainer => | |
| _onSecondaryContainer ??= Color(_scheme.onSecondaryContainer); | |
| @override | |
| Color get secondaryFixed => _secondaryFixed ??= Color(_scheme.secondaryFixed); | |
| @override | |
| Color get secondaryFixedDim => | |
| _secondaryFixedDim ??= Color(_scheme.secondaryFixedDim); | |
| @override | |
| Color get onSecondaryFixed => | |
| _onSecondaryFixed ??= Color(_scheme.onSecondaryFixed); | |
| @override | |
| Color get onSecondaryFixedVariant => | |
| _onSecondaryFixedVariant ??= Color(_scheme.onSecondaryFixedVariant); | |
| @override | |
| Color get tertiary => _tertiary ??= Color(_scheme.tertiary); | |
| @override | |
| Color get onTertiary => _onTertiary ??= Color(_scheme.onTertiary); | |
| @override | |
| Color get tertiaryContainer => | |
| _tertiaryContainer ??= Color(_scheme.tertiaryContainer); | |
| @override | |
| Color get onTertiaryContainer => | |
| _onTertiaryContainer ??= Color(_scheme.onTertiaryContainer); | |
| @override | |
| Color get tertiaryFixed => _tertiaryFixed ??= Color(_scheme.tertiaryFixed); | |
| @override | |
| Color get tertiaryFixedDim => | |
| _tertiaryFixedDim ??= Color(_scheme.tertiaryFixedDim); | |
| @override | |
| Color get onTertiaryFixed => | |
| _onTertiaryFixed ??= Color(_scheme.onTertiaryFixed); | |
| @override | |
| Color get onTertiaryFixedVariant => | |
| _onTertiaryFixedVariant ??= Color(_scheme.onTertiaryFixedVariant); | |
| @override | |
| Color get error => _error ??= Color(_scheme.error); | |
| @override | |
| Color get onError => _onError ??= Color(_scheme.onError); | |
| @override | |
| Color get errorContainer => _errorContainer ??= Color(_scheme.errorContainer); | |
| @override | |
| Color get onErrorContainer => | |
| _onErrorContainer ??= Color(_scheme.onErrorContainer); | |
| @override | |
| ColorScheme copyWith({ | |
| Brightness? brightness, | |
| Color? primary, | |
| Color? onPrimary, | |
| Color? primaryContainer, | |
| Color? onPrimaryContainer, | |
| Color? primaryFixed, | |
| Color? primaryFixedDim, | |
| Color? onPrimaryFixed, | |
| Color? onPrimaryFixedVariant, | |
| Color? secondary, | |
| Color? onSecondary, | |
| Color? secondaryContainer, | |
| Color? onSecondaryContainer, | |
| Color? secondaryFixed, | |
| Color? secondaryFixedDim, | |
| Color? onSecondaryFixed, | |
| Color? onSecondaryFixedVariant, | |
| Color? tertiary, | |
| Color? onTertiary, | |
| Color? tertiaryContainer, | |
| Color? onTertiaryContainer, | |
| Color? tertiaryFixed, | |
| Color? tertiaryFixedDim, | |
| Color? onTertiaryFixed, | |
| Color? onTertiaryFixedVariant, | |
| Color? error, | |
| Color? onError, | |
| Color? errorContainer, | |
| Color? onErrorContainer, | |
| Color? surface, | |
| Color? onSurface, | |
| Color? surfaceDim, | |
| Color? surfaceBright, | |
| Color? surfaceContainerLowest, | |
| Color? surfaceContainerLow, | |
| Color? surfaceContainer, | |
| Color? surfaceContainerHigh, | |
| Color? surfaceContainerHighest, | |
| Color? onSurfaceVariant, | |
| Color? outline, | |
| Color? outlineVariant, | |
| Color? shadow, | |
| Color? scrim, | |
| Color? inverseSurface, | |
| Color? onInverseSurface, | |
| Color? inversePrimary, | |
| Color? surfaceTint, | |
| Color? background, | |
| Color? onBackground, | |
| Color? surfaceVariant, | |
| }) => | |
| brightness != null && | |
| background != null && | |
| onBackground != null && | |
| surface != null && | |
| surfaceDim != null && | |
| surfaceBright != null && | |
| surfaceContainerLowest != null && | |
| surfaceContainerLow != null && | |
| surfaceContainer != null && | |
| surfaceContainerHigh != null && | |
| surfaceContainerHighest != null && | |
| onSurface != null && | |
| surfaceVariant != null && | |
| onSurfaceVariant != null && | |
| outline != null && | |
| outlineVariant != null && | |
| inverseSurface != null && | |
| onInverseSurface != null && | |
| shadow != null && | |
| scrim != null && | |
| surfaceTint != null && | |
| primary != null && | |
| onPrimary != null && | |
| primaryContainer != null && | |
| onPrimaryContainer != null && | |
| primaryFixed != null && | |
| primaryFixedDim != null && | |
| onPrimaryFixed != null && | |
| onPrimaryFixedVariant != null && | |
| inversePrimary != null && | |
| secondary != null && | |
| onSecondary != null && | |
| secondaryContainer != null && | |
| onSecondaryContainer != null && | |
| secondaryFixed != null && | |
| secondaryFixedDim != null && | |
| onSecondaryFixed != null && | |
| onSecondaryFixedVariant != null && | |
| tertiary != null && | |
| onTertiary != null && | |
| tertiaryContainer != null && | |
| onTertiaryContainer != null && | |
| tertiaryFixed != null && | |
| tertiaryFixedDim != null && | |
| onTertiaryFixed != null && | |
| onTertiaryFixedVariant != null && | |
| error != null && | |
| onError != null && | |
| errorContainer != null && | |
| onErrorContainer != null | |
| ? ColorScheme( | |
| brightness: brightness, | |
| // ignore: deprecated_member_use | |
| background: background, | |
| // ignore: deprecated_member_use | |
| onBackground: onBackground, | |
| surface: surface, | |
| surfaceDim: surfaceDim, | |
| surfaceBright: surfaceBright, | |
| surfaceContainerLowest: surfaceContainerLowest, | |
| surfaceContainerLow: surfaceContainerLow, | |
| surfaceContainer: surfaceContainer, | |
| surfaceContainerHigh: surfaceContainerHigh, | |
| surfaceContainerHighest: surfaceContainerHighest, | |
| onSurface: onSurface, | |
| // ignore: deprecated_member_use | |
| surfaceVariant: surfaceVariant, | |
| onSurfaceVariant: onSurfaceVariant, | |
| outline: outline, | |
| outlineVariant: outlineVariant, | |
| inverseSurface: inverseSurface, | |
| onInverseSurface: onInverseSurface, | |
| shadow: shadow, | |
| scrim: scrim, | |
| surfaceTint: surfaceTint, | |
| primary: primary, | |
| onPrimary: onPrimary, | |
| primaryContainer: primaryContainer, | |
| onPrimaryContainer: onPrimaryContainer, | |
| primaryFixed: primaryFixed, | |
| primaryFixedDim: primaryFixedDim, | |
| onPrimaryFixed: onPrimaryFixed, | |
| onPrimaryFixedVariant: onPrimaryFixedVariant, | |
| inversePrimary: inversePrimary, | |
| secondary: secondary, | |
| onSecondary: onSecondary, | |
| secondaryContainer: secondaryContainer, | |
| onSecondaryContainer: onSecondaryContainer, | |
| secondaryFixed: secondaryFixed, | |
| secondaryFixedDim: secondaryFixedDim, | |
| onSecondaryFixed: onSecondaryFixed, | |
| onSecondaryFixedVariant: onSecondaryFixedVariant, | |
| tertiary: tertiary, | |
| onTertiary: onTertiary, | |
| tertiaryContainer: tertiaryContainer, | |
| onTertiaryContainer: onTertiaryContainer, | |
| tertiaryFixed: tertiaryFixed, | |
| tertiaryFixedDim: tertiaryFixedDim, | |
| onTertiaryFixed: onTertiaryFixed, | |
| onTertiaryFixedVariant: onTertiaryFixedVariant, | |
| error: error, | |
| onError: onError, | |
| errorContainer: errorContainer, | |
| onErrorContainer: onErrorContainer, | |
| ) | |
| : brightness != null || | |
| background != null || | |
| onBackground != null || | |
| surface != null || | |
| surfaceDim != null || | |
| surfaceBright != null || | |
| surfaceContainerLowest != null || | |
| surfaceContainerLow != null || | |
| surfaceContainer != null || | |
| surfaceContainerHigh != null || | |
| surfaceContainerHighest != null || | |
| onSurface != null || | |
| surfaceVariant != null || | |
| onSurfaceVariant != null || | |
| outline != null || | |
| outlineVariant != null || | |
| inverseSurface != null || | |
| onInverseSurface != null || | |
| shadow != null || | |
| scrim != null || | |
| surfaceTint != null || | |
| primary != null || | |
| onPrimary != null || | |
| primaryContainer != null || | |
| onPrimaryContainer != null || | |
| primaryFixed != null || | |
| primaryFixedDim != null || | |
| onPrimaryFixed != null || | |
| onPrimaryFixedVariant != null || | |
| inversePrimary != null || | |
| secondary != null || | |
| onSecondary != null || | |
| secondaryContainer != null || | |
| onSecondaryContainer != null || | |
| secondaryFixed != null || | |
| secondaryFixedDim != null || | |
| onSecondaryFixed != null || | |
| onSecondaryFixedVariant != null || | |
| tertiary != null || | |
| onTertiary != null || | |
| tertiaryContainer != null || | |
| onTertiaryContainer != null || | |
| tertiaryFixed != null || | |
| tertiaryFixedDim != null || | |
| onTertiaryFixed != null || | |
| onTertiaryFixedVariant != null || | |
| error != null || | |
| onError != null || | |
| errorContainer != null || | |
| onErrorContainer != null | |
| ? _LazyColorScheme( | |
| _scheme, | |
| brightness: brightness ?? _brightness, | |
| background: background ?? _background, | |
| onBackground: onBackground ?? _onBackground, | |
| surface: surface ?? _surface, | |
| surfaceDim: surfaceDim ?? _surfaceDim, | |
| surfaceBright: surfaceBright ?? _surfaceBright, | |
| surfaceContainerLowest: | |
| surfaceContainerLowest ?? _surfaceContainerLowest, | |
| surfaceContainerLow: surfaceContainerLow ?? _surfaceContainerLow, | |
| surfaceContainer: surfaceContainer ?? _surfaceContainer, | |
| surfaceContainerHigh: surfaceContainerHigh ?? _surfaceContainerHigh, | |
| surfaceContainerHighest: | |
| surfaceContainerHighest ?? _surfaceContainerHighest, | |
| onSurface: onSurface ?? _onSurface, | |
| surfaceVariant: surfaceVariant ?? _surfaceVariant, | |
| onSurfaceVariant: onSurfaceVariant ?? _onSurfaceVariant, | |
| outline: outline ?? _outline, | |
| outlineVariant: outlineVariant ?? _outlineVariant, | |
| inverseSurface: inverseSurface ?? _inverseSurface, | |
| onInverseSurface: onInverseSurface ?? _onInverseSurface, | |
| shadow: shadow ?? _shadow, | |
| scrim: scrim ?? _scrim, | |
| surfaceTint: surfaceTint ?? _surfaceTint, | |
| primary: primary ?? _primary, | |
| onPrimary: onPrimary ?? _onPrimary, | |
| primaryContainer: primaryContainer ?? _primaryContainer, | |
| onPrimaryContainer: onPrimaryContainer ?? _onPrimaryContainer, | |
| primaryFixed: primaryFixed ?? _primaryFixed, | |
| primaryFixedDim: primaryFixedDim ?? _primaryFixedDim, | |
| onPrimaryFixed: onPrimaryFixed ?? _onPrimaryFixed, | |
| onPrimaryFixedVariant: | |
| onPrimaryFixedVariant ?? _onPrimaryFixedVariant, | |
| inversePrimary: inversePrimary ?? _inversePrimary, | |
| secondary: secondary ?? _secondary, | |
| onSecondary: onSecondary ?? _onSecondary, | |
| secondaryContainer: secondaryContainer ?? _secondaryContainer, | |
| onSecondaryContainer: onSecondaryContainer ?? _onSecondaryContainer, | |
| secondaryFixed: secondaryFixed ?? _secondaryFixed, | |
| secondaryFixedDim: secondaryFixedDim ?? _secondaryFixedDim, | |
| onSecondaryFixed: onSecondaryFixed ?? _onSecondaryFixed, | |
| onSecondaryFixedVariant: | |
| onSecondaryFixedVariant ?? _onSecondaryFixedVariant, | |
| tertiary: tertiary ?? _tertiary, | |
| onTertiary: onTertiary ?? _onTertiary, | |
| tertiaryContainer: tertiaryContainer ?? _tertiaryContainer, | |
| onTertiaryContainer: onTertiaryContainer ?? _onTertiaryContainer, | |
| tertiaryFixed: tertiaryFixed ?? _tertiaryFixed, | |
| tertiaryFixedDim: tertiaryFixedDim ?? _tertiaryFixedDim, | |
| onTertiaryFixed: onTertiaryFixed ?? _onTertiaryFixed, | |
| onTertiaryFixedVariant: | |
| onTertiaryFixedVariant ?? _onTertiaryFixedVariant, | |
| error: error ?? _error, | |
| onError: onError ?? _onError, | |
| errorContainer: errorContainer ?? _errorContainer, | |
| onErrorContainer: onErrorContainer ?? _onErrorContainer, | |
| ) | |
| : this; | |
| @override | |
| void debugFillProperties(DiagnosticPropertiesBuilder properties) { | |
| super.debugFillProperties(properties); | |
| properties | |
| ..add(_EnumProperty<Brightness>.lazy("brightness", () => brightness)) | |
| ..add(_ColorProperty.lazy("primary", () => primary)) | |
| ..add(_ColorProperty.lazy("onPrimary", () => onPrimary)) | |
| ..add(_ColorProperty.lazy("primaryContainer", () => primaryContainer)) | |
| ..add(_ColorProperty.lazy("onPrimaryContainer", () => onPrimaryContainer)) | |
| ..add(_ColorProperty.lazy("primaryFixed", () => primaryFixed)) | |
| ..add(_ColorProperty.lazy("primaryFixedDim", () => primaryFixedDim)) | |
| ..add(_ColorProperty.lazy("onPrimaryFixed", () => onPrimaryFixed)) | |
| ..add( | |
| _ColorProperty.lazy( | |
| "onPrimaryFixedVariant", | |
| () => onPrimaryFixedVariant, | |
| ), | |
| ) | |
| ..add(_ColorProperty.lazy("secondary", () => secondary)) | |
| ..add(_ColorProperty.lazy("onSecondary", () => onSecondary)) | |
| ..add(_ColorProperty.lazy("secondaryContainer", () => secondaryContainer)) | |
| ..add( | |
| _ColorProperty.lazy("onSecondaryContainer", () => onSecondaryContainer), | |
| ) | |
| ..add(_ColorProperty.lazy("secondaryFixed", () => secondaryFixed)) | |
| ..add(_ColorProperty.lazy("secondaryFixedDim", () => secondaryFixedDim)) | |
| ..add(_ColorProperty.lazy("onSecondaryFixed", () => onSecondaryFixed)) | |
| ..add( | |
| _ColorProperty.lazy( | |
| "onSecondaryFixedVariant", | |
| () => onSecondaryFixedVariant, | |
| ), | |
| ) | |
| ..add(_ColorProperty.lazy("tertiary", () => tertiary)) | |
| ..add(_ColorProperty.lazy("onTertiary", () => onTertiary)) | |
| ..add(_ColorProperty.lazy("tertiaryContainer", () => tertiaryContainer)) | |
| ..add( | |
| _ColorProperty.lazy("onTertiaryContainer", () => onTertiaryContainer), | |
| ) | |
| ..add(_ColorProperty.lazy("tertiaryFixed", () => tertiaryFixed)) | |
| ..add(_ColorProperty.lazy("tertiaryFixedDim", () => tertiaryFixedDim)) | |
| ..add(_ColorProperty.lazy("onTertiaryFixed", () => onTertiaryFixed)) | |
| ..add( | |
| _ColorProperty.lazy( | |
| "onTertiaryFixedVariant", | |
| () => onTertiaryFixedVariant, | |
| ), | |
| ) | |
| ..add(_ColorProperty.lazy("error", () => error)) | |
| ..add(_ColorProperty.lazy("onError", () => onError)) | |
| ..add(_ColorProperty.lazy("errorContainer", () => errorContainer)) | |
| ..add(_ColorProperty.lazy("onErrorContainer", () => onErrorContainer)) | |
| ..add(_ColorProperty.lazy("surface", () => surface)) | |
| ..add(_ColorProperty.lazy("onSurface", () => onSurface)) | |
| ..add(_ColorProperty.lazy("surfaceDim", () => surfaceDim)) | |
| ..add(_ColorProperty.lazy("surfaceBright", () => surfaceBright)) | |
| ..add( | |
| _ColorProperty.lazy( | |
| "surfaceContainerLowest", | |
| () => surfaceContainerLowest, | |
| ), | |
| ) | |
| ..add( | |
| _ColorProperty.lazy("surfaceContainerLow", () => surfaceContainerLow), | |
| ) | |
| ..add(_ColorProperty.lazy("surfaceContainer", () => surfaceContainer)) | |
| ..add( | |
| _ColorProperty.lazy("surfaceContainerHigh", () => surfaceContainerHigh), | |
| ) | |
| ..add( | |
| _ColorProperty.lazy( | |
| "surfaceContainerHighest", | |
| () => surfaceContainerHighest, | |
| ), | |
| ) | |
| ..add(_ColorProperty.lazy("onSurfaceVariant", () => onSurfaceVariant)) | |
| ..add(_ColorProperty.lazy("outline", () => outline)) | |
| ..add(_ColorProperty.lazy("outlineVariant", () => outlineVariant)) | |
| ..add(_ColorProperty.lazy("shadow", () => shadow)) | |
| ..add(_ColorProperty.lazy("scrim", () => scrim)) | |
| ..add(_ColorProperty.lazy("inverseSurface", () => inverseSurface)) | |
| ..add(_ColorProperty.lazy("onInverseSurface", () => onInverseSurface)) | |
| ..add(_ColorProperty.lazy("inversePrimary", () => inversePrimary)) | |
| ..add(_ColorProperty.lazy("surfaceTint", () => surfaceTint)) | |
| ..add(_ColorProperty.lazy("background", () => background)) | |
| ..add(_ColorProperty.lazy("onBackground", () => onBackground)) | |
| ..add(_ColorProperty.lazy("surfaceVariant", () => surfaceVariant)); | |
| } | |
| @override | |
| bool operator ==(Object other) => | |
| identical(this, other) || | |
| other is _LazyColorScheme && | |
| _scheme == other._scheme && | |
| _brightness == other._brightness && | |
| _background == other._background && | |
| _onBackground == other._onBackground && | |
| _surface == other._surface && | |
| _surfaceDim == other._surfaceDim && | |
| _surfaceBright == other._surfaceBright && | |
| _surfaceContainerLowest == other._surfaceContainerLowest && | |
| _surfaceContainerLow == other._surfaceContainerLow && | |
| _surfaceContainer == other._surfaceContainer && | |
| _surfaceContainerHigh == other._surfaceContainerHigh && | |
| _surfaceContainerHighest == other._surfaceContainerHighest && | |
| _onSurface == other._onSurface && | |
| _surfaceVariant == other._surfaceVariant && | |
| _onSurfaceVariant == other._onSurfaceVariant && | |
| _outline == other._outline && | |
| _outlineVariant == other._outlineVariant && | |
| _inverseSurface == other._inverseSurface && | |
| _onInverseSurface == other._onInverseSurface && | |
| _shadow == other._shadow && | |
| _scrim == other._scrim && | |
| _surfaceTint == other._surfaceTint && | |
| _primary == other._primary && | |
| _onPrimary == other._onPrimary && | |
| _primaryContainer == other._primaryContainer && | |
| _onPrimaryContainer == other._onPrimaryContainer && | |
| _primaryFixed == other._primaryFixed && | |
| _primaryFixedDim == other._primaryFixedDim && | |
| _onPrimaryFixed == other._onPrimaryFixed && | |
| _onPrimaryFixedVariant == other._onPrimaryFixedVariant && | |
| _inversePrimary == other._inversePrimary && | |
| _secondary == other._secondary && | |
| _onSecondary == other._onSecondary && | |
| _secondaryContainer == other._secondaryContainer && | |
| _onSecondaryContainer == other._onSecondaryContainer && | |
| _secondaryFixed == other._secondaryFixed && | |
| _secondaryFixedDim == other._secondaryFixedDim && | |
| _onSecondaryFixed == other._onSecondaryFixed && | |
| _onSecondaryFixedVariant == other._onSecondaryFixedVariant && | |
| _tertiary == other._tertiary && | |
| _onTertiary == other._onTertiary && | |
| _tertiaryContainer == other._tertiaryContainer && | |
| _onTertiaryContainer == other._onTertiaryContainer && | |
| _tertiaryFixed == other._tertiaryFixed && | |
| _tertiaryFixedDim == other._tertiaryFixedDim && | |
| _onTertiaryFixed == other._onTertiaryFixed && | |
| _onTertiaryFixedVariant == other._onTertiaryFixedVariant && | |
| _error == other._error && | |
| _onError == other._onError && | |
| _errorContainer == other._errorContainer && | |
| _onErrorContainer == other._onErrorContainer; | |
| @override | |
| int get hashCode => Object.hash( | |
| Object.hash( | |
| Object.hash( | |
| _scheme, | |
| _brightness, | |
| _background, | |
| _onBackground, | |
| _surface, | |
| _surfaceDim, | |
| _surfaceBright, | |
| _surfaceContainerLowest, | |
| _surfaceContainerLow, | |
| _surfaceContainer, | |
| _surfaceContainerHigh, | |
| _surfaceContainerHighest, | |
| _onSurface, | |
| _surfaceVariant, | |
| _onSurfaceVariant, | |
| _outline, | |
| _outlineVariant, | |
| _inverseSurface, | |
| _onInverseSurface, | |
| _shadow, | |
| ), | |
| _scrim, | |
| _surfaceTint, | |
| _primary, | |
| _onPrimary, | |
| _primaryContainer, | |
| _onPrimaryContainer, | |
| _primaryFixed, | |
| _primaryFixedDim, | |
| _onPrimaryFixed, | |
| _onPrimaryFixedVariant, | |
| _inversePrimary, | |
| _secondary, | |
| _onSecondary, | |
| _secondaryContainer, | |
| _onSecondaryContainer, | |
| _secondaryFixed, | |
| _secondaryFixedDim, | |
| _onSecondaryFixed, | |
| _onSecondaryFixedVariant, | |
| ), | |
| _tertiary, | |
| _onTertiary, | |
| _tertiaryContainer, | |
| _onTertiaryContainer, | |
| _tertiaryFixed, | |
| _tertiaryFixedDim, | |
| _onTertiaryFixed, | |
| _onTertiaryFixedVariant, | |
| _error, | |
| _onError, | |
| _errorContainer, | |
| _onErrorContainer, | |
| ); | |
| } | |
| class _EnumProperty<T extends Enum?> extends DiagnosticsProperty<T> { | |
| _EnumProperty( | |
| String super.name, | |
| super.value, { | |
| super.defaultValue, | |
| super.level, | |
| }); | |
| _EnumProperty.lazy( | |
| String super.name, | |
| super.computeValue, { | |
| super.defaultValue, | |
| super.level, | |
| }) : super.lazy(); | |
| @override | |
| String valueToString({TextTreeConfiguration? parentConfiguration}) => | |
| value?.name ?? "null"; | |
| } | |
| class _ColorProperty extends DiagnosticsProperty<Color> { | |
| _ColorProperty( | |
| String super.name, | |
| super.value, { | |
| super.showName, | |
| super.defaultValue, | |
| super.style, | |
| super.level, | |
| }); | |
| _ColorProperty.lazy( | |
| String super.name, | |
| super.computeValue, { | |
| super.showName, | |
| super.defaultValue, | |
| super.style, | |
| super.level, | |
| }) : super.lazy(); | |
| @override | |
| Map<String, Object?> toJsonMap(DiagnosticsSerializationDelegate delegate) { | |
| final json = super.toJsonMap(delegate); | |
| if (value != null) { | |
| json["valueProperties"] = <String, Object>{ | |
| "red": (value!.r * 255.0).round().clamp(0, 255), | |
| "green": (value!.g * 255.0).round().clamp(0, 255), | |
| "blue": (value!.b * 255.0).round().clamp(0, 255), | |
| "alpha": (value!.a * 255.0).round().clamp(0, 255), | |
| }; | |
| } | |
| return json; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment