Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created June 2, 2025 17:20
Show Gist options
  • Save fredgrott/a238c02fad059b195b98b51d6bc77dec to your computer and use it in GitHub Desktop.
Save fredgrott/a238c02fad059b195b98b51d6bc77dec to your computer and use it in GitHub Desktop.
m3e design system enforcement of color scheme generation
// Copyright 2025 Fredrick Allan Grott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:flutter/material.dart';
/// DesignSystemColorScheme is a way to enforce
/// Material 3 Expressive within the FlexColorScheme generation
/// via the fromSeeds constructor.
///
/// This way multiple apps can be designed with the same basic
/// functions generating the ColorSchemes.
///
/// In this use case I am using 3 brand colors, but the function
/// allows up to 3 brand colors as keys. We want to use the most
/// dominant color as primary and second dominant color as the
/// secondary.
///
/// The FlexSchemeVariant specifies a pre-defined tone set that is
/// used in the ColorScheme generation. The variants that
/// corespond with Material 3 Expressive are:
/// tonalSpot
/// fidelity
/// monochrome
/// neutral
/// vibrant
/// expressive
/// content
/// rainbow
/// fruitSalad
///
///
/// Note that with the highContrast variants for highContrast ColorSchemes
/// one can specify a non highcontrast variant and just move contrast level
/// to a value of 1.0. Or we could use the Monochrom or Neutral for
/// high contrast themes with contgrast level set back to zero.
///
/// @author Fredrick Allan Grott
class DesignSystemColorScheme {
DesignSystemColorScheme();
Color primaryKey = const Color(0xfff77f7f);
Color secondaryKey = const Color(0xffdd7e51);
Color tertiaryKey = const Color(0xffddcfcf);
FlexSchemeVariant variantLight = FlexSchemeVariant.vibrant;
FlexSchemeVariant variantDark = FlexSchemeVariant.vibrant;
FlexSchemeVariant variantLightHighContrast = FlexSchemeVariant.vibrant;
FlexSchemeVariant variantDarkHighContrast = FlexSchemeVariant.vibrant;
double contrastLevelNoContrastTheme = 0.0;
double contrasLevelHighContrast = 1.0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment