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'; | |
extension BuildContextExtensions on BuildContext { | |
ThemeData get theme => Theme.of(this); | |
TextTheme get textTheme => theme.textTheme; | |
ColorScheme get colorScheme => theme.colorScheme; | |
DefaultTextStyle get defaultTextStyle => DefaultTextStyle.of(this); |
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
/// `ThemeExtension` template for custom text styles. | |
/// | |
/// If your goal is to only change the text color for light/dark mode, I don't see a big benefit from this extension. | |
/// For the default text style in the Text widget, you can set `textTheme.bodyMedium` in `ThemeData` (example: lib/app_theme.dart). | |
/// And to set text color for specific widgets, you can use `style: TextStyle(color: Theme.of(context).appColors.error)` or | |
/// `style: AppTypography.h1.copyWith(color: context.theme.appColors.error)`. | |
class AppTextThemeExtension extends ThemeExtension<AppTextThemeExtension> { | |
const AppTextThemeExtension({ | |
required this.displayLarge, | |
required this.displayMedium, |
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'; | |
/// `ThemeExtension` template for custom colors. | |
/// | |
/// For example purposes, it has all required fields from the default Material `ColorScheme`. | |
/// But you can add, rename and delete any fields your need. | |
/// | |
/// ### Motivation | |
/// | |
/// At the beginning, you may not know if your colors will fit into the Material `ColorScheme`, |
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/rendering.dart'; | |
class MeasureSizeRenderObject extends RenderProxyBox { | |
MeasureSizeRenderObject(this.onChanged); | |
Size? oldSize; | |
final ValueChanged<Size> onChanged; | |
@override |