diff --git a/.fvmrc b/.fvmrc index 3cb9a9b..c300356 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,3 +1,3 @@ { - "flutter": "beta" + "flutter": "stable" } \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0fd3672..5d61151 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -39,7 +39,7 @@ jobs: - name: Install Flutter and Dart SDK uses: subosito/flutter-action@v2 with: - channel: 'beta' + channel: 'stable' - name: "Show Dart SDK version" run: dart --version - name: "Show Flutter SDK version" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a6d4776..dacb88c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: - name: "Install Flutter and Dart SDK" uses: subosito/flutter-action@v2 with: - channel: "beta" + channel: "stable" - name: "Show Dart SDK version" run: dart --version - name: "Show Flutter SDK version" diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ff173d..20663f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,35 +2,47 @@ All notable changes to the **FlexSeedScheme** (FSS) package are documented here. -## 2.0.0-dev.1 +## 2.0.0 -**May 13, 2024** +**May 14, 2024** -This release adds support for the revised Material-3 `ColorScheme` released in Flutter version 3.22. +This release adds support for the revised Material-3 `ColorScheme` released in Flutter version 3.22.0 and for seeded scheme variants, that will arrive in the Flutter stable release after 3.22.x. * **CHANGE** - * Bring the internal Material Color Utilities (MCU) library version to parity with its latest package release 0.11.1. Flutter SDK stable 3.22 still uses MCU 0.8.0, but the Flutter master channel is using MCU 0.11.1. + * Bring the internal Material Color Utilities (MCU) library version to parity with its latest package release 0.11.1. Flutter SDK stable 3.22 still uses MCU 0.8.0, but the Flutter master channel already uses MCU 0.11.1. * The `FlexPaletteType.extended` tones got two new tones added, tone 2, and 24. It now has 27 tones. * **NEW** - * Support revised Material-3 `ColorScheme` with the new colors primaryFixed, primaryFixedDim, onPrimaryFixed, onPrimaryFixedVariant, secondaryFixed, secondaryFixedDim, onSecondaryFixed, onSecondaryFixedVariant, tertiaryFixed, tertiaryFixedDim, onTertiaryFixed, onTertiaryFixedVariant, surfaceDim, surfaceBright, surfaceContainerLowest, surfaceContainerLow, surfaceContainer, surfaceContainerHigh and surfaceContainerHighest. + * Support revised Material-3 `ColorScheme` with the new colors `primaryFixed`, `primaryFixedDim`, `onPrimaryFixed`, `onPrimaryFixedVariant`, `secondaryFixed`, `secondaryFixedDim`, `onSecondaryFixed`, `onSecondaryFixedVariant`, `tertiaryFixed`, `tertiaryFixedDim`, `onTertiaryFixed`, `onTertiaryFixedVariant`, `surfaceDim`, `surfaceBright`, `surfaceContainerLowest`, `surfaceContainerLow`, `surfaceContainer`, `surfaceContainerHigh` and `surfaceContainerHighest`. - * New optional way to specify used seeding algorithm in `SeedColorScheme.fromSeeds` by providing new enum value `FlexSchemeVariant` to its `variant` property. + * New alternative way to specify the used seeding algorithm in `SeedColorScheme.fromSeeds` by providing new enum value `FlexSchemeVariant` to its `variant` property. + * In addition to supporting selection of built-in `FlexTones`, the `variant` property also supports using Flutter SDK, MCU based scheme variants `tonalSpot`, `monochrome`, `neutral`, `vibrant`, `expressive`, `content`,`rainbow` and `fruitSalad` in by specifying them in property `variant` in `SeedColorScheme.fromSeeds`. In Flutter 3.22 only the default `tonalSpot` is available, but with FSS you can use any of the other variants as well already in Flutter 3.22. The other variants are not yet available in Flutter 3.22, but they are available in the `ColorScheme` API in the master channel and will be available in Flutter `ColorScheme.fromSeed` in the next stable release after 3.22. With FSS you can use them already starting from Flutter 3.22.0. + * With the `variants` enum property you can also select built-in `FlexTones` that you could use before in `SeedColorScheme.fromSeeds` in `tones`. The `FlexTones` are still available and can be used as before, it has some advantages. With `tones` you can create customized seed extractions based on `FlexTones` and you can use tones surface quick modifiers, `onMainsUseBW`, `onSurfacesUseBW` and `surfacesUseBW`. + * When using `variants`, if the variant is one of the Flutter SDK/MCU variants, it will not use more than one key color, the primary as seed color. The `FlexSchemeVariant` that have their property `isFlutterScheme` set to true are part of the Flutter SDK/MCU variants. + * The Flutter SDK/MCU variants are `tonalSpot`, `fidelity`, `monochrome`, `neutral`, `vibrant`, `expressive`, `content`, `rainbow` and `fruitSalad`. + * The other `FlexSchemeVariant` that have their property `isFlutterScheme` set to false are part of the `FlexTones` variants using the corresponding built-in `FlexTones` as seed extraction. The variants are `material`, `material3Legacy`, `soft`, `vivid`, `vividSurfaces`, `highContrast`, `ultraContrast`, `jolly`, `vividBackground`, `oneHue`, `candyPop` and `chroma`. The `chroma` option is similar to the new nice SDK/MCU one called `fidelity`, in that it follows chroma of seed color, with the added benefit that it can use a separate seed color for each tonal palette. + * The APIs `variant` and `tones` are mutually exclusive, you can only use one of them in `SeedColorScheme.fromSeeds`. Both can be unspecified, but if you specify one, the other must be unspecified/null. - * In addition to supporting selection of previously built-in `FlexTones`, the `variant` property also supports using Flutter SDK scheme variants `tonalSpot`, `monochrome`, `neutral`, `vibrant`, `expressive`, `content`,`rainbow` and `fruitSalad` in property `variant` in `SeedColorScheme.fromSeeds`. In Flutter 3.22 only the default `tonalSpot` is available, but with FSS you can use any of the other variants as well already in Flutter 3.22. The other variants are not yet available in Flutter 3.22, but they are available in the `ColorScheme` API in the master channel and will be available in Flutter `ColorScheme.fromSeed` as well, in the next stable release after 3.22. With FSS you can use them already starting from Flutter 3.22.0. + * A new `FlexTones.material3Legacy` was added. This `FlexTones` configuration preserves and provides access to the seed generation used by Flutter prior to Flutter version 3.22 and as used by `FlexTones.material`in FlexSeedScheme before version 2.0.0. If you in Flutter 3.22 and FlexSeedScheme 2.0.0 need to replicate this style you can use this `FlexTones` in `SeedColorScheme.fromSeeds` property `tones` or the `FlexSchemeVariant.material3Legacy` in `variants`. * **BREAKING** * The Material-3 `ColorScheme` colors `background`, `onBackground` and `surfaceVariant` have been deprecated since they are also deprecated in Flutter 3.22. - * These **deprecated** colors are still supported in `SeedColorScheme.fromSeeds` and `FlexTones`, but will be removed in a future release. They are replaced by `surface` and newer colors like `surfaceDim`, `surfaceBright` and `surfaceContainerLowest` in the new Material-3 `ColorScheme` in Flutter 3.22. - * The fact that these deprecated colors are still referenced in the package will reduce its **pub.dev** score with 10 points, but it is kept for now to maintain compatibility with Flutter 3.22 that also still provides values for the deprecated colors. This package needs to provide the same values to be fully compatible. The `ColorScheme` colors `background`, `onBackground` and `surfaceVariant` may only be fully removed when they have been removed from the Flutter SDK stable channel. They may, if they can be removed without breaking any styles, be removed in a future release of this package, even if they are still available in the Flutter SDK stable channel. + * These **deprecated** colors are **still supported** in `SeedColorScheme.fromSeeds` and `FlexTones`, but they will be removed in a future release. They are replaced by `surface`, `onSurface` and `surfaceContainerLowest`. There are also many new surface colors, like `surfaceDim`, `surfaceBright` and `surfaceContainerLowest` in the new Material-3 `ColorScheme` in Flutter 3.22. + * The fact that these deprecated colors are still **referenced** in the package **will reduce** its **pub.dev** score with **10 points**, but they are kept for now to maintain **FULL** compatibility with **Flutter 3.22** that also still provides values for these deprecated colors and uses them in code. This package needs to provide the same values to be fully compatible. The `ColorScheme` colors `background`, `onBackground` and `surfaceVariant` may only be fully removed when they have been removed from the Flutter SDK stable channel. If later tests show they can be removed without breaking any styles earlier, they will be removed in a future release of this package, even if they are still available in the Flutter SDK stable channel. A future dev version may also remove them to provide compatibility with the Flutter master channel when they are removed there. * **BREAKING STYLES** * All built-in `FlexTones` now use the `paletteType` extended via `FlexPaletteType.extended` as default for additional tone fidelity. This is needed for compatibility with Flutter 3.22 and its revised `ColorScheme`. - * The default tones for the built-in `FlexTones` have been adjusted to match the new Material-3 `ColorScheme` in Flutter 3.22. The new tones and default styles are marginally different but also better than in previous Flutter versions. If you need the result and style used in Flutter 3.19 and earlier, you can use the `FlexTones.material3Legacy` as `tones` in `SeedColorScheme.fromSeeds` to get the result `FlexTones.material` produced in FSS before version 2.0.0 and that was default in Flutter in version 3.19 and earlier. + + * The default tones for the built-in `FlexTones` have been adjusted to match the new Material-3 `ColorScheme` in Flutter 3.22. The new tones and default styles are marginally different but also better than in previous Flutter versions. If you need the result and style used in Flutter 3.19 and earlier, you can use the `FlexTones.material3Legacy` as `tones` in `SeedColorScheme.fromSeeds` to get the result `FlexTones.material` produced in FSS before version 2.0.0 and that was also the default in Flutter in version 3.19 and earlier. + + + * The `FlexSchemeVariant.tonalSpot` is the `variant` that Flutter SDK uses from MCU in `ColorScheme.fromSeed` in **Flutter 3.22 and later** when you make seed generated color schemes with it. This generated scheme is different from the one `ColorScheme.fromSeed` generated in **Flutter 3.19 and earlier**. If you need the result and style used in Flutter 3.19 and earlier, you can use the `material3Legacy` as `tones` or `variant` in `SeedColorScheme.fromSeeds` to get the result `FlexTones.material` produced in FSS before version 2.0.0 and that was also the default in Flutter in version 3.19 and earlier when using `ColorScheme.fromSeed`. + + * The `FlexTones.material` has been updated and now produces the same result as `tonalSpot` in tests. There may be some edge cases where there are rounding differences. The `material` alternative can be used both in `variant` and `tones`. It provides the advantages over `tonalSpot` that since it is a `FlexTones`, it can use multiple seed colors and if used in `tones`, its results can be quick adjusted with `onMainsUseBW`, `onSurfacesUseBW` and `surfacesUseBW`. The `tonalSpot` is a Flutter SDK/MCU variant and does not support these customizations. ## 1.5.0 diff --git a/README.md b/README.md index 64d5875..a4176ac 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,15 @@ # FlexSeedScheme (FSS) -A more flexible and powerful version of Flutter's ColorScheme.fromSeed. +A more flexible and powerful version of Flutter's `ColorScheme.fromSeed`. Use this package like `ColorScheme.fromSeed` with the following additional capabilities: -* Use separate key colors to generate seed-based tonal palettes for primary and optionally secondary, tertiary as well as error, neutral and neutral variant colors in `ColorScheme`. +* Use separate seed key colors to generate seed-based tonal palettes for primary and optionally secondary, tertiary as well as error, neutral and neutral variant colors in `ColorScheme`. * Change the chroma limits and values used in the Material-3 default strategy for tonal palette generation in the new Google HCT (Hue-Chroma-Tone) color space. -* Get access to new Material-3 design `ColorScheme` variants like `fidelity` and `monochrome` that do not yet exist in Flutter SDK (Flutter 3.22), but will arrive in later versions. -* Change which tones in the generated core tonal palettes are used by which `ColorScheme` color. Changes are limited to the tones from correct core palette for each `ColorScheme` color, but any tone from it can be used. Going up or down one tone is often usable, in some cases even two. -* For more tones use `FlexPaletteType.extended`, that gives access to all the new tones that are used in revised Material-3 design for surfaces and fixed main color. These new tones are used and supported by the standard `ColorScheme` in Flutter 3.22 and later. It is recommended to use `FlexPaletteType.extended` if creating new custom FlexTones. In the package version 2.0.0 and later, `FlexPaletteType.extended` is the default palette type. The older palette type `FlexPaletteType.common` is still available for backwards compatibility, but should be avoided. - -## Background - -This package was extracted from the customizable color scheme seeding engine in the -[**FlexColorScheme**](https://pub.dev/packages/flex_color_scheme) package to its own package. - -This allows developers to use the same customizable `ColorScheme` seeding algorithms used by -**FlexColorScheme**, without using the FlexColorScheme package. -Starting with **FlexColorScheme** version 6 and later, it depends on this package instead. - -If you use **FlexColorScheme** version 6 or later, you do not need to add **FlexSeedScheme** to -use its features, FlexColorScheme exports its API as well. -If you use FlexColorScheme you typically do not even need to use FlexSeedScheme directly, -its usage is baked in and used based on how you configure FlexColorScheme. +* Get access to new Material-3 design `ColorScheme` variants like `fidelity` and `monochrome` that do not yet exist in Flutter SDK v3.22, but will arrive in later versions. +* Change which tones in the generated core tonal palettes are used by which `ColorScheme` color. +* Use `FlexPaletteType.extended`, that gives access to all the new tones that are used in revised Material-3 design for surfaces and fixed main color. The new tones are used and supported by the standard `ColorScheme` in Flutter 3.22 and later. It is recommended to use `FlexPaletteType.extended` if creating new custom `FlexTones`. In the package version 2.0.0 and later, `FlexPaletteType.extended` is the default palette type. The older palette type `FlexPaletteType.common` is available for backwards compatibility, but should be avoided in Flutter 3.22 and later. ## Getting Started @@ -260,10 +246,10 @@ const FlexTones myLightTones = FlexTones.light( onSecondaryTone: 96, // Default is 100 onTertiaryTone: 96, // Default is 100 onErrorTone: 96, // Default is 100 - primaryMinChroma: 55, // Default is 48 + primaryMinChroma: 55, // Default is 36 secondaryChroma: 25, // Default is 16 tertiaryChroma: 40, // Default is 24 - neutralChroma: 5, // Default is 4, avoid very high values in light mode. + neutralChroma: 5, // Default is 6, avoid very high values in light mode. neutralVariantChroma: 10, // Default is 8 paletteType: FlexPaletteType.extended, // Use extended palette type ); @@ -275,10 +261,10 @@ const FlexTones myDarkTones = FlexTones.dark( onSecondaryTone: 6, // Default is 20 onTertiaryTone: 6, // Default is 20 onErrorTone: 6, // Default is 20 - primaryMinChroma: 55, // Default is 48 + primaryMinChroma: 55, // Default is 36 secondaryChroma: 25, // Default is 16 tertiaryChroma: 40, // Default is 24 - neutralChroma: 7, // Default is 4, you can go higher in dark mode than light. + neutralChroma: 7, // Default is 6, you can go higher in dark mode than light. neutralVariantChroma: 14, // Default is 8 paletteType: FlexPaletteType.extended, // Use extended palette type ); @@ -309,7 +295,7 @@ There are two high contrast `FlexTones` configuration pre-made for this. They ar `FlexTones.highContrast`, a colorful high-contrast version, and `FlexTones.ultraContrast`, a less colorful version, a more dark on light in light theme mode, and light on dark in dark mode. -The `FlexTones.canyPop` also creates **very** high contrast theme, with colors that are vibrant and pop, it can also be used for high contrast themes. Depending on seed color input values and its chroma value, `FlexTones.chroma` can also be very vibrant and high contrast. It can also be monochromatic, i.e. gray-scale, if input seed colors have chroma value zero. +The `FlexTones.canyPop` also creates **very** high contrast theme, with colors that are vibrant and pop, it can also be used for high contrast themes. Depending on seed color input values and its chroma value, `FlexTones.chroma` can also be very vibrant and high contrast. It can also be monochromatic, i.e. gray-scale if input seed colors have chroma value zero. ```dart // Make a high contrast light ColorScheme from the seeds. @@ -405,7 +391,7 @@ final ColorScheme schemeLightOnBW = SeedColorScheme.fromSeeds( primaryKey: primarySeedColor, secondaryKey: secondarySeedColor, tertiaryKey: tertiarySeedColor, -tones: FlexTones.material(Brightness.light) + tones: FlexTones.material(Brightness.light) .onMainsUseBW() .onSurfacesUseBW(), ); @@ -444,10 +430,10 @@ final ColorScheme schemeLightOnBW = SeedColorScheme.fromSeeds( primaryKey: primarySeedColor, secondaryKey: secondarySeedColor, tertiaryKey: tertiarySeedColor, -tones: FlexTones.material(Brightness.light) - .onMainsUseBW() - .onSurfacesUseBW() - .surfacesUseBW(), // Make light surface and background white + tones: FlexTones.material(Brightness.light) + .onMainsUseBW() + .onSurfacesUseBW() + .surfacesUseBW(), // Make light surface and background white ); ``` @@ -457,7 +443,7 @@ The included example application uses above color seeding and custom tone mapping. You can also choose any of the built-in pre-configured tone mappings as used seeding strategy. When you select seeding strategy, basic info about is displayed. -You can try a web version of this example for version 2 of FSS [**here**](https://rydmike.com/flexseedscheme/demo-v2). The older demo for version 1 of FSS is still available [**here**](https://rydmike.com/flexseedscheme/demo-v1). +You can try a web version of this example for version 2 of FSS [**here in V2 demo**](https://rydmike.com/flexseedscheme/demo-v2). The older demo for version 1 of FSS is still available [**here in V1 demo**](https://rydmike.com/flexseedscheme/demo-v1). You can choose to use secondary and primary seed colors as additional keys to generate the color schemes. You can also toggle keeping contrasting onColors black & white, or force background and surface colors to be white in light mode and true black in dark mode. You can change the seed colors with a color picker by tapping on the seed colors. You can also modify the default error seed color. @@ -522,3 +508,17 @@ Here we can compare it to an example of Material widgets using the theme created |---------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | candy pop light 4 widgets | candy pop dark 4 widgets | + +## Package Background + +This package was extracted from the customizable color scheme seeding engine in the +[**FlexColorScheme**](https://pub.dev/packages/flex_color_scheme) package to its own package. + +This allows developers to use the same customizable `ColorScheme` seeding algorithms used by +**FlexColorScheme**, without using the FlexColorScheme package. +Starting with **FlexColorScheme** version 6 and later, it depends on this package instead. + +If you use **FlexColorScheme** version 6 or later, you do not need to add **FlexSeedScheme** to +use its features, FlexColorScheme exports its API as well. +If you use FlexColorScheme you typically do not even need to use FlexSeedScheme directly, +its usage is baked in and used based on how you configure FlexColorScheme. \ No newline at end of file diff --git a/example/lib/core/constants/app_data.dart b/example/lib/core/constants/app_data.dart index 1611aad..e965e7d 100644 --- a/example/lib/core/constants/app_data.dart +++ b/example/lib/core/constants/app_data.dart @@ -27,7 +27,7 @@ class AppData { // build numbers. static const String versionMajor = '2'; static const String versionMinor = '0'; - static const String versionPatch = '0-dev.1'; + static const String versionPatch = '0'; static const String versionBuild = '01'; static const String version = '$versionMajor.$versionMinor.$versionPatch ' 'Build-$versionBuild'; diff --git a/example/lib/home/views/pages/home_page.dart b/example/lib/home/views/pages/home_page.dart index c1a7eab..22485cf 100644 --- a/example/lib/home/views/pages/home_page.dart +++ b/example/lib/home/views/pages/home_page.dart @@ -83,7 +83,7 @@ class HomePage extends StatelessWidget { else const ListTile( dense: true, - title: Text('Additional seed generation option are available ' + title: Text('Additional seed generation options are available ' 'when using FlexTones based scheme variants.'), ), const Divider(), diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index 4bc9ac6..90ab4f2 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -15,7 +15,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 + url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 diff --git a/example/pubspec.lock b/example/pubspec.lock index 73a361e..52d5039 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -71,7 +71,7 @@ packages: path: ".." relative: true source: path - version: "2.0.0-dev.1" + version: "2.0.0" flutter: dependency: "direct main" description: flutter @@ -294,4 +294,4 @@ packages: version: "0.5.1" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=3.22.0-0.3.pre" + flutter: ">=3.22.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 743bbbd..96c1189 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,16 +1,16 @@ name: flex_seed_scheme_example description: Example that demonstrate how to use the FlexSeedScheme package. -version: 2.0.0-dev.1 +version: 2.0.0 publish_to: 'none' environment: sdk: '>=3.0.0 <4.0.0' - flutter: '>=3.22.0-0.3.pre' + flutter: '>=3.22.0' dependencies: - # Adds the Cupertino Icons font to your application. Used by the + # Add Cupertino Icons font to your application. Used by the # CupertinoIcons class for iOS style icons, by Google flutter.dev. # https://pub.dev/packages/cupertino_icons - cupertino_icons: ^1.0.6 + cupertino_icons: ^1.0.8 # Color picker package, by Mike Rydstrom, rydmike.com (@rydmike). # Used for color selection in the Playground to make customized color schemes. diff --git a/lib/flex_seed_scheme.dart b/lib/flex_seed_scheme.dart index ceb91ee..99bc394 100644 --- a/lib/flex_seed_scheme.dart +++ b/lib/flex_seed_scheme.dart @@ -21,23 +21,25 @@ export 'src/flex/flex_scheme_variant.dart'; /// Extension on `ColorScheme` to give us `SeedColorScheme.fromSeeds`. export 'src/flex/flex_seed_scheme.dart' show SeedColorScheme; -/// A palette with 15 tones using same Hue and Chroma. +/// A palette with predefined tones using same Hue and Chroma. /// -/// The Material default Tonal Palette includes 13 tones, FlexSeedScheme -/// FlexTonalPalette provides 15 when using [FlexPaletteType.common]. +/// The Material Color Utilities default Tonal Palette includes 13 tones, +/// FlexSeedScheme's FlexTonalPalette provides 15 when using +/// [FlexPaletteType.common]. /// The additional two tones are 5 and 98. Tone 98 provides optional tonal /// fidelity in the light and white end of the palette, and tone 5 a more dark /// tone in the black end of the palette. /// -/// Available tones are [0,5,10,20,30,40,50,60,70,80,90,95,98,99,100]. +/// The [FlexPaletteType.common] tones are +/// 0,5,10,20,30,40,50,60,70,80,90,95,98,99,100. /// -/// To get even mor tones you can use [FlexPaletteType.extended] which provides -/// 25 tones, the additional tones are [4,6,12,17,22,87,92,94,96,97] for a total -/// of 25 tones, which are -/// [0,4,5,6,10,12,17,20,22,30,40,50,60,70,80,87,90,92,94,95,96,97,98,99,100]. +/// To get even more tones you can use [FlexPaletteType.extended] which provides +/// 25 tones, the additional tones are 2,4,6,12,17,22,24,87,92,94,96,97 for a +/// total of 27 tones, which are +/// 0,2,4,5,6,10,12,17,20,22,24,30,40,50,60,70,80,87,90,92,94,95,96,97,98,99,100 /// /// The new tones are also used by the new [ColorScheme] in updated Material-3 -/// design system. +/// design system that landed in Flutter 3.22.0. export 'src/flex/flex_tonal_palette.dart'; /// Defines which tone to use from each tonal palette, when assigning @@ -57,7 +59,10 @@ export 'src/flex/flex_tones.dart'; /// * TonalPalette /// * ViewingConditions /// -/// More APIs from MCU may be exported later if needed. +/// More APIs from MCU can be exported if needed, let us know if needed. +/// The ones exported here are the ones used by FlexSeedScheme, its example +/// FlexColorPicker and FlexColorScheme and its example, like the example 5 +/// the Themes Playground. export 'src/mcu/material_color_utilities.dart' show Blend, diff --git a/lib/src/flex/flex_seed_scheme.dart b/lib/src/flex/flex_seed_scheme.dart index 6b75313..1803a01 100644 --- a/lib/src/flex/flex_seed_scheme.dart +++ b/lib/src/flex/flex_seed_scheme.dart @@ -524,7 +524,8 @@ extension SeedColorScheme on ColorScheme { /// key colors when generating each tonal palette. /// /// If not provided, a setup matching the Material 3 Color System - /// specification is used. To create seed generated [ColorScheme] with + /// specification is used by defaulting to [FlexTones.material]. + /// To create seed generated [ColorScheme] with /// different chroma limits and tonal mappings provide a custom [FlexTones], /// or use a predefined one like [FlexTones.jolly], [FlexTones.vivid] or /// [FlexTones.highContrast]. @@ -540,22 +541,21 @@ extension SeedColorScheme on ColorScheme { /// An optional way to select the used algorithm for seeded [ColorScheme] /// generation, can be used instead of a [FlexTones] provided in [tones]. /// - /// If used and a non null value is given, any seed generation configuration - /// provided via [tones] is ignored and the [variant] is used to select - /// a predefined seed generation configuration. + /// The [variant] and [tones] are mutually exclusive, only one of them + /// can be used. If both are null, the default from [tones] is used. /// /// The [variant] selections includes all the Flutter SDK defined options /// that will be available in the future in Flutter Stable after 3.22.x, /// that are available in master channel now but did not land in Flutter /// 3.22. Variant options that are identical to the Flutter SDK options /// have [FlexSchemeVariant.value], [isFlutterScheme] set to true. These - /// enum options will not respect and use any other seed generation key + /// enum options will not respect and use any other seed generation keys /// than the [primaryKey], as they only support using one seed color. /// /// The [FlexSchemeVariant] also includes quick selections for all the /// predefined [FlexTones] configurations. However, with [variant] you can /// only select one of the predefined configurations, and not make custom - /// configurations like you can with [FlexTones]. Additionally you can not + /// configurations like you can with [FlexTones]. Additionally you cannot /// use the [FlexTones] modifiers [onMainsUseBW], [onSurfacesUseBW] and /// [surfacesUseBW], since the only operate on the [FlexTones] /// configurations passed in to [tones]. diff --git a/lib/src/flex/flex_tonal_palette.dart b/lib/src/flex/flex_tonal_palette.dart index b26d479..3276a4b 100644 --- a/lib/src/flex/flex_tonal_palette.dart +++ b/lib/src/flex/flex_tonal_palette.dart @@ -11,9 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - import 'package:collection/collection.dart' show ListEquality; -import 'package:meta/meta.dart'; +import 'package:flutter/foundation.dart'; import '../mcu/hct/hct.dart'; @@ -33,26 +32,46 @@ import '../mcu/hct/hct.dart'; /// When using the [FlexPaletteType.extended] type tones, there are not only /// the new tones, but the chroma limit of tones >= 90 is also removed. /// This increases fidelity of higher tone when high chromacity is used. +/// +/// Starting from Flutter 3.22 and FlexSeedScheme 2.0.0 the common tones +/// should be avoided and extended tones used instead. The common tones are +/// kept for backwards compatibility and for cases where the original M3 +/// palette is needed. The [FlexPaletteType.extended] is the new default +/// for all [FlexTones]. enum FlexPaletteType { - /// Default common tones consisting of the 15 tones originally used in + /// Common tones consisting of the 15 tones originally used in /// FlexSeedScheme. /// - /// Original Material 3 color system included 13 tones + /// Original Material 3 color system included only 13 tones /// 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 99, 100. + /// These are still used as common tone in Material Color Utilities (MCU) + /// package TonalPalette class. /// /// FlexSeedScheme includes tones 5 and 98 in addition to these tones in its /// definition of common tones. + /// + /// Starting from Flutter 3.22 and FlexSeedScheme 2.0.0 the common tones + /// should be avoided and extended tones used instead. The common tones are + /// kept for backwards compatibility and for cases where the original M3 + /// palette is needed. The [FlexPaletteType.extended] is the new default + /// for all [FlexTones]. common, /// Extended tones used in Material 3 revision for additional fidelity /// in surface colors. These were added during 1st half of 2023 to the /// Material 3 color system specification. /// - /// The added tones 4, 6, 12, 17, 22 are for new dark mode surfaces in + /// The added tones 2, 4, 6, 12, 17, 22, 24 are for new dark mode surfaces in /// revised Material 3 dark surface colors. Likewise added tones - /// 96, 94, 92, 87 are for light mode surfaces in the updated Material 3 - /// color system. For more information, see: + /// 98, 97, 96, 94, 92, 87 are for light mode surfaces in the updated + /// Material-3 color system. For more information, see: /// https://m3.material.io/styles/color/the-color-system/color-roles + /// + /// Starting from Flutter 3.22 and FlexSeedScheme 2.0.0 the common tones + /// should be avoided and extended tones used instead. The common tones are + /// kept for backwards compatibility and for cases where the original M3 + /// palette is needed. The [FlexPaletteType.extended] is the new default + /// for all [FlexTones]. extended, } @@ -68,6 +87,12 @@ enum FlexPaletteType { @immutable class FlexTonalPalette { /// Commonly-used tone values. + /// + /// Starting from Flutter 3.22 and FlexSeedScheme 2.0.0 the common tones + /// should be avoided and extended tones used instead. The common tones are + /// kept for backwards compatibility and for cases where the original M3 + /// palette is needed. The [FlexPaletteType.extended] is the new default + /// for all [FlexTones]. static const List commonTones = [ 0, 5, @@ -97,6 +122,12 @@ class FlexTonalPalette { /// to compile time const of same const list length. /// /// Flutter SDK [TonalPalette] has 13 common tones and [FlexTonalPalette] 15. + /// + /// Starting from Flutter 3.22 and FlexSeedScheme 2.0.0 the common tones + /// should be avoided and extended tones used instead. The common tones are + /// kept for backwards compatibility and for cases where the original M3 + /// palette is needed. The [FlexPaletteType.extended] is the new default + /// for all [FlexTones]. static const int commonSize = 15; /// Extended one values in a [FlexTonalPalette]. @@ -114,6 +145,12 @@ class FlexTonalPalette { /// /// Tones 2, 5, and 97 are not in old or new M3 spec, but FlexSeedScheme /// includes them to enable even more fidelity in dark and light tones. + /// + /// Starting from Flutter 3.22 and FlexSeedScheme 2.0.0 the common tones + /// should be avoided and extended tones used instead. The common tones are + /// kept for backwards compatibility and for cases where the original M3 + /// palette is needed. The [FlexPaletteType.extended] is the new default + /// for all [FlexTones]. static const List extendedTones = [ 0, 2, @@ -155,6 +192,12 @@ class FlexTonalPalette { /// to compile time const of same const list length. /// /// Flutter SDK [TonalPalette] has 13 tones, [FlexTonalPalette] extended 27. + /// + /// Starting from Flutter 3.22 and FlexSeedScheme 2.0.0 the common tones + /// should be avoided and extended tones used instead. The common tones are + /// kept for backwards compatibility and for cases where the original M3 + /// palette is needed. The [FlexPaletteType.extended] is the new default + /// for all [FlexTones]. static const int extendedSize = 27; /// The hue of the palette. @@ -173,6 +216,8 @@ class FlexTonalPalette { /// - keys are integers that represent tones, and /// - values are colors in ARGB format. final Map _cache; + + /// Whether the palette was created from the cache or not. final bool _isFromCache; FlexTonalPalette._fromHct( diff --git a/pubspec.lock b/pubspec.lock index eccc05a..4b85047 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -450,4 +450,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=3.22.0-0.3.pre" + flutter: ">=3.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index fd25730..ef2ba60 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flex_seed_scheme description: A more flexible and powerful version of Flutter's ColorScheme.fromSeed. Use multiple seed colors, custom chroma and tone mapping. -version: 2.0.0-dev.1 +version: 2.0.0 homepage: https://github.com/rydmike/flex_seed_scheme repository: https://github.com/rydmike/flex_seed_scheme issue_tracker: https://github.com/rydmike/flex_seed_scheme/issues @@ -29,7 +29,7 @@ topics: environment: sdk: '>=3.0.0 <4.0.0' - flutter: '>=3.22.0-0.3.pre' + flutter: '>=3.22.0' dependencies: # Used by mcu: tonal_palette.dart