Skip to content

Instantly share code, notes, and snippets.

View fredgrott's full-sized avatar
👾
focusing on flutter cross platform mobile dev

Fred Grott fredgrott

👾
focusing on flutter cross platform mobile dev
View GitHub Profile
@fredgrott
fredgrott / snippet.dart
Created January 26, 2026 16:24
using M3ETheme, the dynamic color way
@override
Widget build(BuildContext context) {
return DynamicColorBuilder(
builder: (lightDynamic, darkDynamic){
final light = lightDynamic ?? ColorScheme.fromSeed(seedColor: Colors.teal);
final dark = darkDynamic ??
ColorScheme.fromSeed(seedColor: Colors.teal, brightness: Brightness.dark);
return MaterialApp(
theme: light.toM3EThemeData(override: M3eOverride(colors: M3ECustomColors.from(light),
typography: M3ECustomTypography(base: CustomTextTheme, emphasized: MyM3ECustomEmphasized ),
@fredgrott
fredgrott / snippet.dart
Created January 26, 2026 14:44
using M3ETheme, non dynamic color way
@override
Widget build(BuildContext context) {
final light = ColorScheme.fromSeed(
seedColor: Colors.purple, brightness: Brightness.light);
final dark = ColorScheme.fromSeed(
seedColor: Colors.purple, brightness: Brightness.dark);
return MaterialApp(
title: 'M3E Gallery',
theme: light.toM3EThemeData(override: M3eOverride(colors: M3ECustomColors.from(light),
typography: M3ECustomTypography(base: CustomTextTheme, emphasized: MyM3ECustomEmphasized ),
@fredgrott
fredgrott / snippet.dart
Created January 26, 2026 14:10
M3EEmphasized
/// Expressive emphasis tweaks layered on top of baseline M3 type.
/// Keep line-height the same; only tune weight/letter-spacing for emphasis.
/// For most purposes, the M3ECustomEmphasized() construct is used.
@immutable
class M3ECustomEmphasized {
final TextStyle expressiveDisplayLarge;
final TextStyle expressiveDisplayMedium;
final TextStyle expressiveDisplaySmall;
final TextStyle expressiveHeadlineLarge;
final TextStyle expressiveHeadlineMedium;
@fredgrott
fredgrott / snippet.dart
Created January 23, 2026 16:57
button font size
@immutable
class ButtonFontSize {
final double xs;
final double sm;
final double md;
final double lg;
final double xl;
const ButtonFontSize({this.xs = 14, this.sm = 14, this.md = 16, this.lg = 20, this.xl = 24});
}
@fredgrott
fredgrott / snippet.dart
Created January 23, 2026 16:54
M3ECustomTypography
/// Material 3 Expressive typography tokens.
/// - `base` starts from **M3 (Typography.material2021)**.
/// - Optionally remaps fonts: brand (UI) for display/headline/title/label
/// and plain (reading) for body.
/// - Adds an emphasized set (weight/tracking tweaks) for expressive hierarchy.
@immutable
class M3ECustomTypography {
final TextTheme base;
final M3ECustomEmphasized emphasized;
@fredgrott
fredgrott / snippet.dart
Last active January 23, 2026 16:48
M3ECustomExpressive
/// Expressive emphasis tweaks layered on top of baseline M3 type.
/// Keep line-height the same; only tune weight/letter-spacing for emphasis.
/// For most purposes, the M3ECustomEmphasized() construct is used.
@immutable
class M3ECustomEmphasized {
final TextStyle expressiveDisplayLarge;
final TextStyle expressiveDisplayMedium;
final TextStyle expressiveDisplaySmall;
final TextStyle expressiveHeadlineLarge;
final TextStyle expressiveHeadlineMedium;
@fredgrott
fredgrott / snippet.dart
Created January 23, 2026 16:19
kVarWdth
class kVarWdth {
static const FontVariation displayLarge = FontVariation('wdth', 100);
static const FontVariation displayMedium = FontVariation('wdth', 100);
static const FontVariation displaySmall = FontVariation('wdth', 100);
static const FontVariation headlineLarge = FontVariation('wdth', 100);
static const FontVariation headlineMedium = FontVariation('wdth', 100);
@fredgrott
fredgrott / snippet.dart
Created January 23, 2026 16:14
kFontWeights
class kFontWeights {
final FontWeight displayLarge = FontWeight.w400;
final FontWeight displayMedium = FontWeight.w400;
final FontWeight displaySmall = FontWeight.w400;
final FontWeight headlineLarge = FontWeight.w400;
final FontWeight headlineMedium = FontWeight.w400;
@fredgrott
fredgrott / m_3_e_theme.dart
Created January 23, 2026 15:58
full M3ETheme
// Copyright 2026 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.
//
// Modified from m3e_design package
// Copyright (c) 2025 Emily Moonstone
// MIT Licnese
// ignore_for_file: prefer_constructors_over_static_methods
@fredgrott
fredgrott / snippet.dart
Created January 23, 2026 15:52
colorscheme extension
// Convenience creation helpers to install M3ETheme with minimal boilerplate.
extension M3EColorSchemeAccessors on ColorScheme {
/// Creates a ThemeData from this ColorScheme and installs the M3ETheme
/// extension in one call.
///
/// Example:
/// final theme = ColorScheme.fromSeed(seedColor: Colors.teal).toM3EThemeData();
ThemeData toM3EThemeData({bool useMaterial3 = true, M3ETheme? override, ThemeData? base}) {
final ThemeData seed = base ?? ThemeData(useMaterial3: useMaterial3, colorScheme: this);
return withM3ETheme(seed, override: override);