diff --git a/forui/example/lib/main.dart b/forui/example/lib/main.dart index 97d9350c8..af9511083 100644 --- a/forui/example/lib/main.dart +++ b/forui/example/lib/main.dart @@ -28,6 +28,10 @@ class Application extends StatelessWidget { ); } + + + + class ExampleWidget extends StatefulWidget { const ExampleWidget({super.key}); diff --git a/forui/example/pubspec.lock b/forui/example/pubspec.lock index ba91c6e07..5707f25e9 100644 --- a/forui/example/pubspec.lock +++ b/forui/example/pubspec.lock @@ -498,10 +498,10 @@ packages: dependency: transitive description: name: platform - sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" url: "https://pub.dev" source: hosted - version: "3.1.4" + version: "3.1.5" plugin_platform_interface: dependency: transitive description: diff --git a/forui/lib/src/theme/color_scheme.dart b/forui/lib/src/theme/color_scheme.dart index 3d835b8e5..73a6b6769 100644 --- a/forui/lib/src/theme/color_scheme.dart +++ b/forui/lib/src/theme/color_scheme.dart @@ -1,56 +1,99 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; +import 'package:meta/meta.dart'; + import 'package:forui/forui.dart'; -/// A set of colors that can be used to configure the colors of most widgets. +/// A set of colors that is part of a [FThemeData]. It is used to configure the color properties of Forui widgets. +/// +/// These properties are not used directly by Forui widgets. Instead, they are the defaults for the corresponding colors +/// of widget styles configured via `inherit(...)` constructors. +/// +/// The main color groups in this scheme are [primary], [secondary], [muted], [destructive], and [error]. +/// * Primary colors are used for key widgets across the UI. +/// * Secondary colors are used for less prominent widgets. +/// * Mute colors are typically used for disabled widgets. +/// * Destructive colors are used for destructive actions such as "Delete" buttons. +/// * Error colors are typically used to highlight errors, such as invalid input in text-fields. /// -/// See the pre-defined themes' color schemes in [FThemes]. +/// Each color group includes a `-Foreground` suffixed color, i.e. [primaryForeground], used to color text and other +/// visual elements on top of their respective background colors. +/// +/// See [FThemes] for predefined themes and color schemes. final class FColorScheme with Diagnosticable { - /// The system brightness. + /// + /// This is typically used to determine the appearance of native UI elements such as on-screen keyboards. final Brightness brightness; /// The background color. + /// + /// Typically used as a background for [foreground] colored widgets. final Color background; /// The foreground color. + /// + /// Typically used to color widgets against a [background]. final Color foreground; /// The primary color. + /// + /// Typically used as a background for [primaryForeground] colored widgets. final Color primary; /// The primary foreground color. + /// + /// Typically used to color widgets against a [primary] colored background. final Color primaryForeground; /// The secondary color. + /// + /// Typically used as a background for [secondaryForeground] colored widgets. final Color secondary; /// The secondary foreground color. + /// + /// Typically used to color widgets against a [secondary] colored background. final Color secondaryForeground; /// The muted color. + /// + /// Typically used as a background for [mutedForeground] colored widgets. final Color muted; /// The muted foreground color. + /// + /// Typically used to color widgets against a [muted] colored background. final Color mutedForeground; /// The destructive color. + /// + /// Typically used as a background for [destructiveForeground] colored widgets. final Color destructive; /// The destructive foreground color. + /// + /// Typically used to color widgets against a [destructive] colored background. final Color destructiveForeground; /// The error color. + /// + /// Typically used as a background for [errorForeground] colored widgets. final Color error; /// The error foreground color. + /// + /// Typically used to color widgets against a [error] colored background. final Color errorForeground; /// The border color. final Color border; /// Creates a [FColorScheme]. + /// + /// **Note:** + /// Unless you are creating a completely new color scheme, modifying [FThemes]' predefined color schemes is preferred. const FColorScheme({ required this.brightness, required this.background, @@ -69,7 +112,20 @@ final class FColorScheme with Diagnosticable { }); /// Creates a copy of this [FColorScheme] with the given properties replaced. - FColorScheme copyWith({ + /// + /// ```dart + /// final scheme = FColorScheme( + /// brightness: Brightness.light, + /// background: Colors.blue, + /// // Other arguments omitted for brevity + /// ); + /// + /// final copy = scheme.copyWith(brightness: Brightness.dark); + /// + /// print(copy.brightness); // Brightness.dark + /// print(copy.background); // Colors.blue + /// ``` + @useResult FColorScheme copyWith({ Brightness? brightness, Color? background, Color? foreground, @@ -123,37 +179,38 @@ final class FColorScheme with Diagnosticable { } @override - bool operator ==(Object other) => identical(this, other) || other is FColorScheme && - brightness == other.brightness && - background == other.background && - foreground == other.foreground && - primary == other.primary && - primaryForeground == other.primaryForeground && - secondary == other.secondary && - secondaryForeground == other.secondaryForeground && - muted == other.muted && - mutedForeground == other.mutedForeground && - destructive == other.destructive && - destructiveForeground == other.destructiveForeground && - error == other.error && - errorForeground == other.errorForeground && - border == other.border; + bool operator ==(Object other) => + identical(this, other) || + other is FColorScheme && + brightness == other.brightness && + background == other.background && + foreground == other.foreground && + primary == other.primary && + primaryForeground == other.primaryForeground && + secondary == other.secondary && + secondaryForeground == other.secondaryForeground && + muted == other.muted && + mutedForeground == other.mutedForeground && + destructive == other.destructive && + destructiveForeground == other.destructiveForeground && + error == other.error && + errorForeground == other.errorForeground && + border == other.border; @override int get hashCode => - brightness.hashCode ^ - background.hashCode ^ - foreground.hashCode ^ - primary.hashCode ^ - primaryForeground.hashCode ^ - secondary.hashCode ^ - secondaryForeground.hashCode ^ - muted.hashCode ^ - mutedForeground.hashCode ^ - destructive.hashCode ^ - destructiveForeground.hashCode ^ - error.hashCode ^ - errorForeground.hashCode ^ - border.hashCode; - + brightness.hashCode ^ + background.hashCode ^ + foreground.hashCode ^ + primary.hashCode ^ + primaryForeground.hashCode ^ + secondary.hashCode ^ + secondaryForeground.hashCode ^ + muted.hashCode ^ + mutedForeground.hashCode ^ + destructive.hashCode ^ + destructiveForeground.hashCode ^ + error.hashCode ^ + errorForeground.hashCode ^ + border.hashCode; } diff --git a/forui/lib/src/theme/style.dart b/forui/lib/src/theme/style.dart index 3752fe1d9..913c44843 100644 --- a/forui/lib/src/theme/style.dart +++ b/forui/lib/src/theme/style.dart @@ -1,25 +1,56 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; -/// The fallback global style is used to configure the widget-specific styles if they are not provided. -final class FStyle with Diagnosticable { +import 'package:meta/meta.dart'; + +import 'package:forui/forui.dart'; - /// The border radius. +/// A set of miscellaneous properties that is part of a [FThemeData]. +/// +/// These properties are not used directly by Forui widgets. Instead, they are the defaults for the corresponding +/// properties of widget styles configured via `inherit(...)` constructors. +final class FStyle with Diagnosticable { + /// The border radius. Defaults to `BorderRadius.circular(8)`. final BorderRadius borderRadius; - /// The border width. + /// The border width. Defaults to 1. final double borderWidth; /// Creates an [FStyle]. - FStyle({BorderRadius? borderRadius, double? borderWidth}): - borderRadius = borderRadius ?? BorderRadius.circular(8), - borderWidth = borderWidth ?? 1; + /// + /// **Note:** + /// Unless you are creating a completely new style, modifying [FThemes]' predefined styles should be preferred. + const FStyle({ + this.borderRadius = const BorderRadius.all(Radius.circular(8)), + this.borderWidth = 1, + }); + + /// Creates a copy of this [FStyle] with the given properties replaced. + /// + /// ```dart + /// final style = FStyle( + /// borderRadius: BorderRadius.circular(1), + /// borderWidth: 2, + /// ); + /// + /// final copy = style.copyWith(borderWidth: 3); + /// + /// print(copy.borderRadius); // BorderRadius.circular(1) + /// print(copy.borderWidth); // 3 + /// ``` + @useResult FStyle copyWith({ + BorderRadius? borderRadius, + double? borderWidth, + }) => FStyle( + borderRadius: borderRadius ?? this.borderRadius, + borderWidth: borderWidth ?? this.borderWidth, + ); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(DiagnosticsProperty('borderRadius', borderRadius, defaultValue: BorderRadius.circular(8))) + ..add(DiagnosticsProperty('borderRadius', borderRadius, defaultValue: BorderRadius.circular(8))) ..add(DoubleProperty('borderWidth', borderWidth, defaultValue: 1)); } @@ -33,5 +64,4 @@ final class FStyle with Diagnosticable { @override int get hashCode => borderRadius.hashCode ^ borderWidth.hashCode; - } diff --git a/forui/lib/src/theme/theme.dart b/forui/lib/src/theme/theme.dart index a93b7f15c..c0d515b27 100644 --- a/forui/lib/src/theme/theme.dart +++ b/forui/lib/src/theme/theme.dart @@ -1,33 +1,95 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:meta/meta.dart'; + import 'package:forui/forui.dart'; -/// Represents a Forui theme. +/// Applies a theme to descendant widgets. +/// +/// A theme configures the colors and typographic choices of Forui widgets. The actual configuration is stored in +/// a [FThemeData]. Descendant widgets obtain the current theme's [FThemeData] via either [ThemeBuildContext.theme], +/// or [FTheme.of]. When a widget uses either, it is automatically rebuilt if the theme later changes. +/// +/// ```dart +/// class Parent extends StatelessWidget { +/// @override +/// Widget build(BuildContext context) => FTheme( +/// data: FThemes.zinc.light, +/// child: Child(), +/// ); +/// } +/// +/// class Child extends StatelessWidget { +/// @override +/// Widget build(BuildContext context) { +/// final FThemeData theme = context.theme; +/// final FThemeData sameTheme = FTheme.of(context); +/// +/// return const Placeholder(); +/// } +/// } +/// ``` /// -/// See [ThemeBuildContext.theme] for accessing the current theme. +/// See [FThemeData] which describes of the actual configuration of a theme. class FTheme extends StatelessWidget { - - /// Retrieves the current theme data. + /// Returns the current [FThemeData], or [FThemes.zinc.light] if there is no ancestor [FTheme]. + /// + /// It is recommended to use the terser [ThemeBuildContext.theme] getter instead. + /// + /// ## Troubleshooting: + /// + /// ### [FTheme.of] always returns [FThemes.zinc.light] + /// + /// One of the most common causes is calling [FTheme.of] in the same context which [FTheme] was declared. To fix this, + /// move the call to [FTheme.of] to a descendant widget. /// - /// It is recommended to use [ThemeBuildContext.theme] to access the current theme instead. - static FThemeData of(BuildContext context) { + /// ✅ Do: + /// ```dart + /// class Parent extends StatelessWidget { + /// @override + /// Widget build(BuildContext context) => FTheme( + /// data: FThemes.zinc.light, + /// child: Child(), + /// ); + /// } + /// + /// class Child extends StatelessWidget { + /// @override + /// Widget build(BuildContext context) { + /// final FThemeData theme = FTheme.of(context); + /// return const SomeWidget(theme: theme); + /// } + /// } + /// ``` + /// + /// ❌ Do not: + /// ```dart + /// class Parent extends StatelessWidget { + /// @override + /// Widget build(BuildContext context) => FTheme( + /// data: FThemes.zinc.light, + /// child: SomeWidget( + /// theme: FTheme.of(context), // Whoops! + /// ), + /// ); + /// } + /// ``` + @useResult static FThemeData of(BuildContext context) { final theme = context.dependOnInheritedWidgetOfExactType<_InheritedTheme>(); return theme?.data ?? FThemes.zinc.light; } - /// The theme data. + /// The color and typography values for descendant Forui widgets. final FThemeData data; - /// The text direction. - /// - /// If none is provided, the text direction is inherited from the context. + /// The text direction. Defaults to the text direction inherited from its nearest ancestor. final TextDirection? textDirection; - /// The child widget. + /// The widget below this widget in the tree. final Widget child; - /// Creates a [FTheme]. + /// Creates a [FTheme] that applies [data] to all descendant widgets in [child]. const FTheme({ required this.data, required this.child, @@ -57,7 +119,6 @@ class FTheme extends StatelessWidget { ..add(DiagnosticsProperty('data', data, showName: false)) ..add(EnumProperty('textDirection', textDirection)); } - } class _InheritedTheme extends InheritedWidget { @@ -78,10 +139,46 @@ class _InheritedTheme extends InheritedWidget { /// Provides functions for accessing the current [FThemeData]. extension ThemeBuildContext on BuildContext { - /// Retrieves the current [FThemeData] from an ancestor [FTheme]. Defaults to [FThemes.zinc.light] if there is no - /// ancestor [FTheme]. + /// Returns the current [FThemeData], or [FThemes.zinc.light] if there is no ancestor [FTheme]. + /// + /// ## Troubleshooting: + /// + /// ### [theme] always returns [FThemes.zinc.light] + /// + /// One of the most common causes is calling [theme] in the same context which [FTheme] was declared. To fix this, + /// move the call to [theme] to a descendant widget. + /// + /// ✅ Do: + /// ```dart + /// class Parent extends StatelessWidget { + /// @override + /// Widget build(BuildContext context) => FTheme( + /// data: FThemes.zinc.light, + /// child: Child(), + /// ); + /// } + /// + /// class Child extends StatelessWidget { + /// @override + /// Widget build(BuildContext context) { + /// final FThemeData theme = context.theme; + /// return const SomeWidget(theme: theme); + /// } + /// } + /// ``` /// - /// This is a convenience method for [FTheme.of]. + /// ❌ Do not: + /// ```dart + /// class Parent extends StatelessWidget { + /// @override + /// Widget build(BuildContext context) => FTheme( + /// data: FThemes.zinc.light, + /// child: SomeWidget( + /// theme: context.theme, // Whoops! + /// ), + /// ); + /// } + /// ``` FThemeData get theme => FTheme.of(this); } diff --git a/forui/lib/src/theme/theme_data.dart b/forui/lib/src/theme/theme_data.dart index 1a5719cd8..f195e88b5 100644 --- a/forui/lib/src/theme/theme_data.dart +++ b/forui/lib/src/theme/theme_data.dart @@ -1,19 +1,31 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter/rendering.dart'; + +import 'package:meta/meta.dart'; import 'package:forui/forui.dart'; -/// The color scheme, typography, overarching style, and widget specific styles used to configure child Forui widgets. -class FThemeData with Diagnosticable { - /// The color scheme. +/// Defines the configuration of the overall visual [FTheme] for a widget subtree. +/// +/// A [FThemeData] is composed of [colorScheme], [typography], [style], and widget styles. +/// * [colorScheme] is a set of colors. +/// * [typography] contains font and typography information. +/// * [style] is a set of miscellaneous properties. +/// * widget styles are used to style individual Forui widgets. +/// +/// [FThemeData] and widget styles provide an `inherit(...)` constructor. The constructor configures the theme data/ +/// widget style using the defaults provided by the [colorScheme], [typography], and [style]. +final class FThemeData with Diagnosticable { + /// The color scheme. It is used to configure the color properties of Forui widgets. final FColorScheme colorScheme; - /// The typography data. + /// The typography data. It is used to configure the [TextStyle]s of Forui widgets. final FTypography typography; - /// The overarching style. + /// The style. It is used to configure the miscellaneous properties, such as border radii, of Forui widgets. final FStyle style; - /// The chip styles. + /// The badge styles. final FBadgeStyles badgeStyles; /// The button styles. @@ -41,10 +53,13 @@ class FThemeData with Diagnosticable { final FSwitchStyle switchStyle; /// Creates a [FThemeData]. + /// + /// **Note:** + /// Unless you are creating a completely new theme, modifying [FThemes]' predefined themes is preferred. + /// [FThemeData.inherit] can also be used as a simpler way to create a [FThemeData] without manually specifying the + /// widget styles. FThemeData({ required this.colorScheme, - required this.typography, - required this.style, required this.badgeStyles, required this.buttonStyles, required this.cardStyle, @@ -54,13 +69,15 @@ class FThemeData with Diagnosticable { required this.boxStyle, required this.separatorStyles, required this.switchStyle, + this.typography = const FTypography(), + this.style = const FStyle(), }); - /// Creates a [FThemeData] that inherits the given properties. + /// Creates a [FThemeData] that configures the widget styles using the given properties. FThemeData.inherit({ required this.colorScheme, - required this.typography, - required this.style, + this.typography = const FTypography(), + this.style = const FStyle(), }) : badgeStyles = FBadgeStyles.inherit(colorScheme: colorScheme, typography: typography, style: style), buttonStyles = FButtonStyles.inherit( colorScheme: colorScheme, @@ -76,7 +93,22 @@ class FThemeData with Diagnosticable { switchStyle = FSwitchStyle.inherit(colorScheme: colorScheme); /// Creates a copy of this [FThemeData] with the given properties replaced. - FThemeData copyWith({ + /// + /// ```dart + /// final foo = FTypography(); + /// final bar = FTypography(); + /// + /// final theme = FThemeData.inherit( + /// colorScheme: FColorScheme(...), + /// typography: foo, + /// ); + /// + /// final copy = theme.copyWith(typography: bar); + /// + /// print(theme.colorScheme == copy.colorScheme); // true + /// print(copy.typography); // bar + /// ``` + @useResult FThemeData copyWith({ FColorScheme? colorScheme, FTypography? typography, FStyle? style, diff --git a/forui/lib/src/theme/themes.dart b/forui/lib/src/theme/themes.dart index db48af43e..c094a18c8 100644 --- a/forui/lib/src/theme/themes.dart +++ b/forui/lib/src/theme/themes.dart @@ -8,7 +8,6 @@ extension FThemes on Never { /// The light and dark variants of the [Zinc](https://ui.shadcn.com/themes) theme. static final zinc = ( light: FThemeData.inherit( - typography: FTypography(), colorScheme: const FColorScheme( brightness: Brightness.light, background: Color(0xFFFFFFFF), @@ -25,10 +24,8 @@ extension FThemes on Never { errorForeground: Color(0xFFFAFAFA), border: Color(0xFFE4E4E7), ), - style: FStyle(), ), dark: FThemeData.inherit( - typography: FTypography(), colorScheme: const FColorScheme( brightness: Brightness.dark, background: Color(0xFF09090B), @@ -45,7 +42,6 @@ extension FThemes on Never { errorForeground: Color(0xFFFAFAFA), border: Color(0xFF27272A), ), - style: FStyle(), ), ); diff --git a/forui/lib/src/theme/typography.dart b/forui/lib/src/theme/typography.dart index 13ab553a0..f315d8806 100644 --- a/forui/lib/src/theme/typography.dart +++ b/forui/lib/src/theme/typography.dart @@ -1,24 +1,26 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; -import 'package:sugar/core.dart'; +import 'package:meta/meta.dart'; import 'package:forui/forui.dart'; // TODO: replace with nullable number operations in Sugar 4. double? _scale(double? value, double factor) => value == null ? null : value * factor; -/// A Forui typography used to configure the Forui widgets' [TextStyle]s. +/// Definitions for the various typographical styles that are part of a [FThemeData]. /// -/// It is usually inherited from an ancestor [FTheme]. Besides the typical font information, a [FTypography] also contains -/// scalar values used to scale a [TextStyle]'s corresponding properties. This ensures that various [TextStyle]s with the -/// same font are scaled consistently throughout a project. +/// A [FTypography] contains scalar values for scaling a [TextStyle]'s corresponding properties. It also contains labelled +/// font sizes, such as [FTypography.xs], which are based on [Tailwind CSS](https://tailwindcss.com/docs/font-size). +/// +/// The scaling is applied automatically in all Forui widgets while the labelled font sizes are used as the defaults +/// for the corresponding properties of widget styles configured via `inherit(...)` constructors. final class FTypography with Diagnosticable { /// The default font family. Defaults to [`packages/forui/Inter`](https://fonts.google.com/specimen/Inter). /// /// ## Contract: - /// Throws an [AssertionError] if blank. + /// Throws an [AssertionError] if empty. final String defaultFontFamily; /// A value used to scale [TextStyle.fontSize]. Defaults to 1. @@ -150,7 +152,7 @@ final class FTypography with Diagnosticable { final double xl8; /// Creates a [FTypography]. - FTypography({ + const FTypography({ this.defaultFontFamily = 'packages/forui/Inter', this.sizeScalar = 1, this.letterSpacingScalar = 1, @@ -169,7 +171,7 @@ final class FTypography with Diagnosticable { this.xl7 = 72, this.xl8 = 96, }): - assert(defaultFontFamily.isNotBlank, 'Font family should not be blank.'), + assert(0 < defaultFontFamily.length, 'The defaultFontFamily should not be empty.'), assert(0 < sizeScalar, 'The sizeScalar is $sizeScalar, but it should be in the range "0 < sizeScalar".'), assert(0 < letterSpacingScalar, 'The letterSpacingScalar is $letterSpacingScalar, but it should be in the range "0 < letterSpacingScalar".'), assert(0 < wordSpacingScalar, 'The wordSpacingScalar is $wordSpacingScalar, but it should be in the range "0 < wordSpacingScalar".'), @@ -188,7 +190,19 @@ final class FTypography with Diagnosticable { assert(0 < xl8, 'The xl8 is $xl8, but it should be in the range "0 < xl8".'); /// Creates a copy of this [FTypography] with the given properties replaced. - FTypography copyWith({ + /// + /// ```dart + /// const typography = FTypography( + /// defaultFontFamily: 'packages/forui/my-font', + /// sizeScalar: 2, + /// ); + /// + /// final copy = typography.copyWith(sizeScalar: 3); + /// + /// print(copy.defaultFontFamily); // 'packages/forui/my-font' + /// print(copy.sizeScalar); // 3 + /// ``` + @useResult FTypography copyWith({ String? defaultFontFamily, double? sizeScalar, double? letterSpacingScalar, @@ -227,18 +241,18 @@ final class FTypography with Diagnosticable { xl8: xl8 ?? this.xl8, ); - /// Returns a [TextStyle] with the given properties, based on and scaled using this [FTypography]. + /// Returns a [TextStyle] with the given properties, based on, and scaled using this [FTypography]. /// /// ```dart - /// final font = FFont( - /// family: 'packages/forui/my-font', + /// final typography = FTypography( + /// defaultFontFamily: 'packages/forui/my-font', /// sizeScalar: 2, /// letterSpacingScalar: 3, /// wordSpacingScalar: 4, /// heightScalar: 5, /// ); /// - /// final style = font.toTextStyle( + /// final style = typography.toTextStyle( /// fontSize: 1, /// letterSpacing: 1, /// wordSpacing: 1, @@ -251,7 +265,7 @@ final class FTypography with Diagnosticable { /// print(style.wordSpacing); // 4 /// print(style.height); // 5 /// ``` - TextStyle toTextStyle({ + @useResult TextStyle toTextStyle({ bool inherit = true, Color? color, Color? backgroundColor, @@ -372,7 +386,7 @@ final class FTypography with Diagnosticable { /// Provides functions for working with [FTypography]s. extension TypographyTextStyle on TextStyle { - /// Returns a [TextStyle] scaled using the given [typography]. + /// Scales a [TextStyle] using the given [typography]. /// /// ```dart /// final typography = FTypography( @@ -397,7 +411,7 @@ extension TypographyTextStyle on TextStyle { /// print(style.wordSpacing); // 4 /// print(style.height); // 5 /// ``` - TextStyle scale(FTypography typography) => copyWith( + @useResult TextStyle scale(FTypography typography) => copyWith( fontSize: _scale(fontSize, typography.sizeScalar), letterSpacing: _scale(letterSpacing, typography.letterSpacingScalar), wordSpacing: _scale(wordSpacing, typography.wordSpacingScalar), diff --git a/forui/test/src/theme/typoegraphy_test.dart b/forui/test/src/theme/typoegraphy_test.dart index 56e00e49d..0a84db1ae 100644 --- a/forui/test/src/theme/typoegraphy_test.dart +++ b/forui/test/src/theme/typoegraphy_test.dart @@ -7,7 +7,7 @@ import 'package:forui/forui.dart'; void main() { group('FTypography', () { - final typography = FTypography( + const typography = FTypography( defaultFontFamily: 'Roboto', sizeScalar: 2, letterSpacingScalar: 3, @@ -17,7 +17,7 @@ void main() { group('constructor', () { test('no arguments', () { - final typography = FTypography(); + const typography = FTypography(); expect(typography.defaultFontFamily, 'packages/forui/Inter'); expect(typography.sizeScalar, 1); expect(typography.letterSpacingScalar, 1); @@ -57,7 +57,7 @@ void main() { }); test('all arguments', () { - final typography = FTypography().copyWith( + final typography = const FTypography().copyWith( defaultFontFamily: 'Roboto', sizeScalar: 2, letterSpacingScalar: 3, @@ -109,7 +109,7 @@ void main() { }); test('debugFillProperties', () { - final font = FTypography( + const font = FTypography( defaultFontFamily: 'Roboto', sizeScalar: 2, letterSpacingScalar: 3, @@ -171,7 +171,7 @@ void main() { }); group('FontTextStyle', () { - final font = FTypography( + const font = FTypography( defaultFontFamily: 'Roboto', sizeScalar: 2, letterSpacingScalar: 3,