Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created February 19, 2026 19:14
Show Gist options
  • Select an option

  • Save fredgrott/7033656a11650e05ed89942e8f04b4cd to your computer and use it in GitHub Desktop.

Select an option

Save fredgrott/7033656a11650e05ed89942e8f04b4cd to your computer and use it in GitHub Desktop.
brand colors model
// ignore_for_file: prefer_constructors_over_static_methods
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
/// Since M3ETheme takes a color scheme as a paremeter
/// the brand colors has to be injected using a immutable
/// model. I.E. this is a template of how you will make
/// your own app brand colors class.
///
/// @author Fredrick Allan Grott
@immutable
class M3EBrandColors {
final Color brandOne;
final Color brandTwo;
final Color brandThree;
const M3EBrandColors({
required this.brandOne,
required this.brandTwo,
required this.brandThree,
});
M3EBrandColors.from(ColorScheme genColorScheme) : brandOne = genColorScheme.primary.harmonizeWith(genColorScheme.primary),
brandTwo = genColorScheme.secondary.harmonizeWith(genColorScheme.primary), brandThree = genColorScheme.tertiary.harmonizeWith(genColorScheme.primary);
static M3EBrandColors lerp(M3EBrandColors a, M3EBrandColors b, double t) => M3EBrandColors(
brandOne: Color.lerp(a.brandOne, b.brandOne, t)!,
brandTwo: Color.lerp(a.brandTwo, b.brandTwo, t)!,
brandThree: Color.lerp(a.brandThree, b.brandThree, t)!,
);
// This will be used to insert your brand colors into
// M3ETheme as M3EBrandColors.copyWith( Your brand colors.harmonizeWith(colorScheme.primary))
M3EBrandColors copyWith({
Color? appBrandOne,
Color? appBrandTwo,
Color? appBrandThree,
}) { return M3EBrandColors(
brandOne: appBrandOne!,
brandTwo: appBrandTwo!,
brandThree: appBrandThree!,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment