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
| /// Inject (or replace) the M3ETheme extension on a ThemeData. | |
| ThemeData withM3ETheme(ThemeData base, {M3ETheme? override}) { | |
| // Use any existing M3ETheme, else the provided override, else defaults. | |
| final current = base.extension<M3ETheme>(); | |
| final next = override ?? current ?? M3ETheme.defaults(base.colorScheme); | |
| // Merge existing extensions (values) with our M3ETheme, replacing prior ones. | |
| final Iterable<ThemeExtension<dynamic>> existing = base.extensions.values; | |
| final List<ThemeExtension<dynamic>> merged = <ThemeExtension<dynamic>>[]; | |
| for (final e in existing) { |
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
| // 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 |
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
| // 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 |
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
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| theme: ThemeData( | |
| extensions: const <ThemeExtension<dynamic>>[ | |
| MyColors(brandColor: Color(0xFF1E88E5), danger: Color(0xFFE53935)), | |
| ], | |
| ), | |
| darkTheme: ThemeData.dark().copyWith( | |
| extensions: <ThemeExtension<dynamic>>[ | |
| const MyColors(brandColor: Color(0xFF90CAF9), danger: Color(0xFFEF9A9A)), |
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/material.dart'; | |
| import 'package:flutter/scheduler.dart'; | |
| /// Flutter code sample for [ThemeExtension]. | |
| @immutable | |
| class MyColors extends ThemeExtension<MyColors> { | |
| const MyColors({required this.brandColor, required this.danger}); | |
| final Color? brandColor; |
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
| // 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. | |
| // | |
| // Modified from window_size_classes package by Yuna | |
| // Copyright 2025 under GNU LGPL 3.0 | |
| // ignore_for_file: avoid_classes_with_only_static_members | |
| import 'package:flutter/widgets.dart'; |
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
| final windowHeight = WindowHeight.of(context); | |
| if (windowHeight == WindowHeight.compact) { | |
| // Adapt UI for limited vertical space | |
| } | |
| Widget build(BuildContext context) { | |
| final windowHeight = WindowHeight.of(context); | |
| // This value can change during the app's lifetime | |
| // Adapt your layout based on available vertical space... |
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
| // 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. | |
| // | |
| // Modified from window_size_classes package by Yuna | |
| // Copyright 2025 under GNU LGPL 3.0 | |
| import 'package:flutter/widgets.dart'; | |
| import 'package:material_expressive_collection/src/adaptive/breakpoints.dart'; | |
| import 'package:meta/meta.dart'; |
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
| final windowWidth = WindowWidth.of(context); | |
| return switch (wiindowWidth) { | |
| WindowWidth.compact => CompactLayout(), | |
| WindowWidth.medium => MediumLayout(), | |
| WindowWidth.expanded => ExpandedLayout(), | |
| _ => LargeLayout(), // large and extraLarge | |
| }; | |
| Widget build(BuildContext context) { |
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
| // 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. | |
| // | |
| // Modified from window_size_classes package by Yuna | |
| // Copyright 2025 under GNU LGPL 3.0 | |
| import 'package:flutter/widgets.dart'; | |
| import 'package:material_expressive_collection/src/adaptive/breakpoints.dart'; | |
| import 'package:meta/meta.dart'; |