From 774c0eedfc975f85bcf28a10b5bce1e964f5c8fa Mon Sep 17 00:00:00 2001 From: rydmike Date: Sun, 29 Dec 2024 00:23:05 +0200 Subject: [PATCH] Chore: Update to RydMike lints 2.3.0 and fix lints --- CHANGELOG.md | 2 +- analysis_options.yaml | 77 ++++++++------ example/analysis_options.yaml | 28 +++++ .../theme/code_theme.dart | 1 + .../theme/topic_theme.dart | 1 + .../import_export_playground_settings.dart | 2 +- .../query_params_handler_web.dart | 8 +- .../utils/vertical_shape_border.dart | 8 +- .../component_screen.dart | 3 +- .../theme_simulator/app_example_shop.dart | 28 ++--- example/lib/shared/utils/breakpoint.dart | 4 + .../universal/responsive_two_widgets.dart | 12 +-- lib/src/flex_alpha_values.dart | 1 + lib/src/flex_color_scheme.dart | 2 + lib/src/flex_constants.dart | 100 ++++++++++++++++++ lib/src/flex_scheme_color.dart | 1 + lib/src/flex_scheme_on_colors.dart | 1 + lib/src/flex_scheme_surface_colors.dart | 1 + .../flex_color_scheme_region_widget_test.dart | 4 +- 19 files changed, 219 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e7eb82f2..0e8968ca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All changes to the **FlexColorScheme** (FCS) package are documented here. ## 8.1.0 -**Dec 28, 2024** +**Dec 29, 2024** ### Package diff --git a/analysis_options.yaml b/analysis_options.yaml index a7e3cdc4b..900d461f7 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,5 +1,4 @@ # RydMike LINTER Preferences v2.3.0 -# TODO(rydmike): Review and publish this v2.3.0 updated version. # # Get this file here: https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c # @@ -7,22 +6,22 @@ # You can find a list of all lint rules to put in your all_lint_rules.yaml file here: # https://dart.dev/tools/linter-rules/all # +# This version is updated for Flutter 3.27 and Dart 3.6. +# # For a comparison of all lint rules settings in rule styles listed below, please see this Google # sheet: https://docs.google.com/spreadsheets/d/1Nc1gFjmCOMubWZD7f2E4fLhWN7LYaOE__tsA7bf2NjA # # Versions used for comparison: -# TODO(rydmike): Update the used comparisons to their latest version. # -# Core v3.0.0 : https://pub.dev/packages/lints -# Recommended v3.0.0 : https://pub.dev/packages/lints -# Flutter Lints v3.0.1 : https://pub.dev/packages/flutter_lints +# Core v5.1.1 : https://pub.dev/packages/lints +# Recommended v5.1.1 : https://pub.dev/packages/lints +# Flutter Lints v5.0.0 : https://pub.dev/packages/flutter_lints # Pedantic v1.11.1 : https://pub.dev/packages/pedantic # Effective Dart v1.3.2 : https://pub.dev/packages/effective_dart # Flutter repo master : https://github.com/flutter/flutter/blob/master/analysis_options.yaml -# Lint v2.2.0 : https://pub.dev/packages/lint -# VG Analysis v5.1.0 : https://pub.dev/packages/very_good_analysis -# RydMike v2.1.0 : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c -# +# Lint v2.3.0 : https://pub.dev/packages/lint +# VG Analysis v7.0.0 : https://pub.dev/packages/very_good_analysis +# RydMike v2.3.0 : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c include: all_lint_rules.yaml analyzer: exclude: @@ -249,6 +248,9 @@ linter: # where we voluntarily want to catch everything, especially as a library. # See https://github.com/dart-lang/linter/issues/3023 # + # The above issue has been resolved and closed, so the rule is now enabled + # starting in version 2.3.0. + # # Other known linters use: # # Core disabled : https://pub.dev/packages/lints @@ -259,8 +261,11 @@ linter: # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml # Lint disabled : https://pub.dev/packages/lint # VG Analysis disabled : https://pub.dev/packages/very_good_analysis - # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c - avoid_catches_without_on_clauses: false + # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + # PACKAGE: enabled : By commenting it out below. + # APPLICATION: disabled : With false value. + # + #avoid_catches_without_on_clauses: false # AVOID defining a class that contains only static members. # @@ -501,8 +506,9 @@ linter: # # https://dart.dev/tools/linter-rules/diagnostic_describe_all_properties.html # - # Consider using this lint rule if you are making a public Flutter package, for private ones and private apps - # we recommend keeping it off as you probably won't be making diagnostic properties for all your + # Consider using this lint rule if you are making a public Flutter package. + # For private ones and private apps we recommend keeping it off as you probably + # won't be making diagnostic properties for all your # classes, unless you are using a data class lib that does it for you via code generation. # # Other known linters use: @@ -513,10 +519,10 @@ linter: # Pedantic disabled : https://pub.dev/packages/pedantic # Effective Dart disabled : https://pub.dev/packages/effective_dart # Lint disabled : https://pub.dev/packages/lint - # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml + # Flutter repo ENABLED? disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml # VG Analysis disabled : https://pub.dev/packages/very_good_analysis # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c - # PACKAGE: enabled : By commenting it out. + # PACKAGE: enabled : By commenting it out, sometimes use it, not always. # APPLICATION: disabled : With false value. (Default, assume we are making an app most of the time.) diagnostic_describe_all_properties: false @@ -549,8 +555,10 @@ linter: # # Document ignore comments. # - # RydMike: THis is good, but putting it false for now, as it is triggered a lot - # in code bases that did not do this. Consider keeping it on for new projects. + # RydMike: This is good, but putting it false for now. This lint is triggered a lot + # in our code bases that did not do this originally. + # Consider enabling it for new projects. May enable later in older projects too and + # add explanations to all the ignored rules. # # Other known linters use: # @@ -561,7 +569,7 @@ linter: # Effective Dart disabled : https://pub.dev/packages/effective_dart # Lint disabled : https://pub.dev/packages/lint # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml - # VG Analysis disabled : https://pub.dev/packages/very_good_analysis + # VG Analysis enabled : https://pub.dev/packages/very_good_analysis # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c document_ignores: false @@ -692,8 +700,8 @@ linter: # Pedantic disabled : https://pub.dev/packages/pedantic # Effective Dart disabled : https://pub.dev/packages/effective_dart # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml - # Lint ? : https://pub.dev/packages/lint - # VG Analysis ? : https://pub.dev/packages/very_good_analysis + # Lint disabled : https://pub.dev/packages/lint + # VG Analysis disabled : https://pub.dev/packages/very_good_analysis # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c omit_obvious_local_variable_types: false @@ -797,8 +805,8 @@ linter: # # https://dart.dev/tools/linter-rules/prefer_expression_function_bodies.html # - # Certainly a good idea in many cases, but not always. For example, not always suitable for - # Flutter, which may have a `build` method with a single return, but that return is still + # Certainly a good idea in many cases, but not always. For example, it is not always suitable for + # Flutter, which may have a `build` method with a single return. This return is still # complex enough that a "body" is worth it, and it might not even fit on a single line. # https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods # @@ -850,7 +858,7 @@ linter: # https://dart.dev/tools/linter-rules/prefer_int_literals.html # # This rule goes against the preferred style of being explicit with - # declarations and hides when a number is double, since we cannot declare it + # declarations and hides when a number is double. We cannot declare it # as 0.0 or 1.0 when it is double, it has to be 0 or 1, making it look # like an integer, even if it is not. Sometimes doing that is OK, but let's # not enforce it. @@ -893,11 +901,11 @@ linter: # Effective Dart enabled : https://pub.dev/packages/effective_dart # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml # Lint disabled : https://pub.dev/packages/lint - # VG Analysis enabled : https://pub.dev/packages/very_good_analysis + # VG Analysis disabled : https://pub.dev/packages/very_good_analysis # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c # PACKAGE: enabled : By commenting it out. (My default, I start with this) # APPLICATION: disabled : With false value. (But usually uncomment the false value if it is an app) - public_member_api_docs: false + #public_member_api_docs: false # DO use trailing commas for all function calls and declarations unless the function call or # definition, from the start of the function name up to the closing parenthesis, @@ -926,13 +934,20 @@ linter: # # We do like this lint rule, but we want to have the default constructor first, followed # by its properties, after this, other named constructors and factories. This rule gets - # in the way of that and forces you to put (often final) constructor properties after all + # in the way of that. It forces you to put (often final) constructor properties after all # the named constructors and factories, making them tedious to find and disconnected from # where we want to see, read and handily edit them. This is especially the case if there are # many constructors and factories, and they have a lot of parameters. For now, we disable - # this rule and order things as described above, which apart from the default constructor - # properties coming right after the constructor, is the only part where we in practice - # deviate from this rule, so other yes, we do put constructors first as well anyway. + # this rule and order things as described above. The default constructor properties coming + # right after the constructor, is the only part where we in practice + # deviate from this rule, so otherwise yes, we do put constructors first as well anyway. + # + # From version v2.3.0 started using this rule, but add exceptions for files with + # classes that have a lot of properties and factory constructors. In those cases, + # we disable this rule, so we can get a better overview of the class properties + # and main constructor, before the factory constructors. + # + # Remove the comment below to disable this rule again. # # Other known linters use: # @@ -945,8 +960,8 @@ linter: # Lint disabled : https://pub.dev/packages/lint # Discussion https://github.com/passsy/dart-lint/issues/1 # VG Analysis enabled : https://pub.dev/packages/very_good_analysis - # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c - sort_constructors_first: false + # RydMike enabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + # sort_constructors_first: false # DON'T use final for local variables. # diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 950676c7d..609b0107f 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -25,6 +25,34 @@ linter: # APPLICATION: disabled : With false value. (Default, assume we are making an app most of the time.) diagnostic_describe_all_properties: false + # AVOID catches without on clauses. + # + # https://dart.dev/tools/linter-rules/avoid_catches_without_on_clauses.html + # + # Using catch clauses without on clauses makes your code prone to encountering unexpected + # errors that won't be thrown (and thus will go unnoticed). However, there are situations + # where we voluntarily want to catch everything, especially as a library. + # See https://github.com/dart-lang/linter/issues/3023 + # + # The above issue has been resolved and closed, so the rule is now enabled + # starting in version 2.3.0, in packages, keeping it disabled in example and + # Playground apps for now. + # + # Other known linters use: + # + # Core disabled : https://pub.dev/packages/lints + # Recommended disabled : https://pub.dev/packages/lints + # Flutter Lints disabled : https://pub.dev/packages/flutter_lints + # Pedantic disabled : https://pub.dev/packages/pedantic + # Effective Dart enabled : https://pub.dev/packages/effective_dart + # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml + # Lint disabled : https://pub.dev/packages/lint + # VG Analysis disabled : https://pub.dev/packages/very_good_analysis + # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + # PACKAGE: enabled : By commenting it out below. + # APPLICATION: disabled : With false value. + avoid_catches_without_on_clauses: false + # DO document all public members. # # https://dart-lang.github.io/linter/lints/public_member_api_docs.html diff --git a/example/lib/example5_themes_playground/theme/code_theme.dart b/example/lib/example5_themes_playground/theme/code_theme.dart index d44af6cdd..ce0f27497 100644 --- a/example/lib/example5_themes_playground/theme/code_theme.dart +++ b/example/lib/example5_themes_playground/theme/code_theme.dart @@ -89,6 +89,7 @@ class CodeTheme extends ThemeExtension { /// A harmonized code view color theme, based on [brightness] where colors /// are harmonized towards a given [sourceColor]. + // ignore: sort_constructors_first factory CodeTheme.harmonized(Color sourceColor, Brightness brightness) { final int sourceColorValue = sourceColor.value32bit; diff --git a/example/lib/example5_themes_playground/theme/topic_theme.dart b/example/lib/example5_themes_playground/theme/topic_theme.dart index 9b5ddfec0..e066e76ed 100644 --- a/example/lib/example5_themes_playground/theme/topic_theme.dart +++ b/example/lib/example5_themes_playground/theme/topic_theme.dart @@ -96,6 +96,7 @@ class TopicTheme extends ThemeExtension { /// A color harmonized topic theme, based on [brightness] where colors /// are harmonized towards a given [sourceColor]. + // ignore: sort_constructors_first factory TopicTheme.harmonized(Color sourceColor, Brightness brightness) { final int sourceColorValue = sourceColor.value32bit; diff --git a/example/lib/example5_themes_playground/utils/import_export_playground_settings.dart b/example/lib/example5_themes_playground/utils/import_export_playground_settings.dart index b076feae1..71178768e 100644 --- a/example/lib/example5_themes_playground/utils/import_export_playground_settings.dart +++ b/example/lib/example5_themes_playground/utils/import_export_playground_settings.dart @@ -55,8 +55,8 @@ enum JsonKeys { typeEnumVisualDensity(key: 'enum_visual_density'), value(key: 'value'); - final String key; const JsonKeys({required this.key}); + final String key; } /// A function that exports the theme playground settings to JSON. diff --git a/example/lib/example5_themes_playground/utils/query_params/query_params_handler_web.dart b/example/lib/example5_themes_playground/utils/query_params/query_params_handler_web.dart index 886446105..1e92aef78 100644 --- a/example/lib/example5_themes_playground/utils/query_params/query_params_handler_web.dart +++ b/example/lib/example5_themes_playground/utils/query_params/query_params_handler_web.dart @@ -18,14 +18,14 @@ const bool _debug = !kReleaseMode && true; /// This implementation listens to URL changes and calls the provided callback /// when the query parameters change. class QueryParamsHandler implements QueryParamsHandlerInterface { - final void Function(Map params) _onParamsChanged; - StreamSubscription? _popStateSubscription; - JSFunction? _locationChangeListener; - QueryParamsHandler(this._onParamsChanged) { _initializeWebListener(); } + final void Function(Map params) _onParamsChanged; + StreamSubscription? _popStateSubscription; + JSFunction? _locationChangeListener; + void _initializeWebListener() { // Listen to PopState events (handles both URL changes and history changes) _popStateSubscription = web.window.onPopState.listen((_) { diff --git a/example/lib/example5_themes_playground/utils/vertical_shape_border.dart b/example/lib/example5_themes_playground/utils/vertical_shape_border.dart index 9040beb41..2097bc5f5 100644 --- a/example/lib/example5_themes_playground/utils/vertical_shape_border.dart +++ b/example/lib/example5_themes_playground/utils/vertical_shape_border.dart @@ -3,16 +3,16 @@ import 'package:flutter/material.dart'; /// A ShapeBorder that can draw left and right side outline borders with /// different thickness and colors. class VerticalShapeBorder extends ShapeBorder { - final double cornerRadius; - final BorderSide leftSide; - final BorderSide rightSide; - const VerticalShapeBorder({ this.cornerRadius = 8.0, this.leftSide = BorderSide.none, this.rightSide = BorderSide.none, }); + final double cornerRadius; + final BorderSide leftSide; + final BorderSide rightSide; + @override EdgeInsetsGeometry get dimensions => EdgeInsets.fromLTRB(leftSide.width, 0, rightSide.width, 0); diff --git a/example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_material3/component_screen.dart b/example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_material3/component_screen.dart index 29db04a83..2acb07e03 100644 --- a/example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_material3/component_screen.dart +++ b/example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_material3/component_screen.dart @@ -365,9 +365,8 @@ class _ButtonsState extends State { } class ButtonsWithoutIcon extends StatelessWidget { - final bool isDisabled; - const ButtonsWithoutIcon({super.key, required this.isDisabled}); + final bool isDisabled; @override Widget build(BuildContext context) { diff --git a/example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_shop.dart b/example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_shop.dart index c242425c8..db105e9f0 100644 --- a/example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_shop.dart +++ b/example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_shop.dart @@ -897,10 +897,10 @@ class _SearchBarState extends State { } class Category { + const Category({required this.title, required this.selections}); + final String title; final List selections; - - Category({required this.title, required this.selections}); } void _pushScreen({required BuildContext context, required Widget screen}) { @@ -911,6 +911,15 @@ void _pushScreen({required BuildContext context, required Widget screen}) { } class Product { + const Product( + {required this.name, + required this.imageUrls, + required this.cost, + this.description, + this.sizes, + required this.category, + required this.productType}); + final String name; final List imageUrls; final double cost; @@ -922,15 +931,6 @@ class Product { /// Represents type of product such as shirt, jeans, pet treats, etc. final String productType; - - Product( - {required this.name, - required this.imageUrls, - required this.cost, - this.description, - this.sizes, - required this.category, - required this.productType}); } class Cart extends ChangeNotifier { @@ -1054,17 +1054,17 @@ class OrderItem { String? selectedColor; } -Category _mensCategory = Category(title: 'Men', selections: [ +Category _mensCategory = const Category(title: 'Men', selections: [ 'Shirts', 'Jeans', 'Shorts', 'Jackets', ]); -Category _womensCategory = Category(title: 'Women', selections: [ +Category _womensCategory = const Category(title: 'Women', selections: [ 'Shirts', 'Jeans', ]); -Category _petsCategory = Category(title: 'Pets', selections: [ +Category _petsCategory = const Category(title: 'Pets', selections: [ 'Toys', 'Treats', ]); diff --git a/example/lib/shared/utils/breakpoint.dart b/example/lib/shared/utils/breakpoint.dart index 87a3f171b..d433f0470 100755 --- a/example/lib/shared/utils/breakpoint.dart +++ b/example/lib/shared/utils/breakpoint.dart @@ -95,6 +95,7 @@ class Breakpoint { /// watch and large desktop classes suitable for 4 screen. /// /// Use a layout builder to get [BoxConstraints] + // ignore: sort_constructors_first factory Breakpoint.fromConstraints( BoxConstraints constraints, { BreakType type = BreakType.material, @@ -149,6 +150,7 @@ class Breakpoint { /// /// Use [Breakpoint.fromConstraints] when the widget does not take up the /// full screen + // ignore: sort_constructors_first factory Breakpoint.fromMediaQuery( BuildContext context, { BreakType type = BreakType.material, @@ -189,6 +191,7 @@ class Breakpoint { /// The private factory [Breakpoint._calcBreakpoint] follows the /// Material Design Guidelines for breakpoints: /// [https://material.io/design/layout/responsive-layout-grid.html#grid-behavior] + // ignore: sort_constructors_first factory Breakpoint._calcBreakpoint({ required Orientation orientation, required double width, @@ -395,6 +398,7 @@ class Breakpoint { /// devices, last one is for 4k and larger screens. The calculation also /// includes and handles breakpoints for upp to 4k screens providing a /// total of max 24 columns instead of max 12 columns as in Material. + // ignore: sort_constructors_first factory Breakpoint._calcBreakpointLarge({ required Orientation orientation, required double width, diff --git a/example/lib/shared/widgets/universal/responsive_two_widgets.dart b/example/lib/shared/widgets/universal/responsive_two_widgets.dart index 403c9a208..ad1ddee4b 100644 --- a/example/lib/shared/widgets/universal/responsive_two_widgets.dart +++ b/example/lib/shared/widgets/universal/responsive_two_widgets.dart @@ -9,6 +9,12 @@ const double _kMinWidth = 550; /// /// Value of [minWidth] defaults to [_kMinWidth]. class ResponsiveTwoWidgets extends StatelessWidget { + const ResponsiveTwoWidgets({ + super.key, + required this.builder, + this.minWidth = _kMinWidth, + }); + final Widget Function( BuildContext context, bool isRow, @@ -16,12 +22,6 @@ class ResponsiveTwoWidgets extends StatelessWidget { final double minWidth; - const ResponsiveTwoWidgets({ - super.key, - required this.builder, - this.minWidth = _kMinWidth, - }); - @override Widget build(BuildContext context) { return LayoutBuilder( diff --git a/lib/src/flex_alpha_values.dart b/lib/src/flex_alpha_values.dart index e397a8ec0..d4d1f30db 100644 --- a/lib/src/flex_alpha_values.dart +++ b/lib/src/flex_alpha_values.dart @@ -94,6 +94,7 @@ class FlexAlphaValues { /// Factory used to get alpha values for a given blend level and blend mode /// and brightness. + // ignore: sort_constructors_first factory FlexAlphaValues.getAlphas( final FlexSurfaceMode mode, final int blendLevel) { switch (mode) { diff --git a/lib/src/flex_color_scheme.dart b/lib/src/flex_color_scheme.dart index 8a94f7280..5e0ef42da 100644 --- a/lib/src/flex_color_scheme.dart +++ b/lib/src/flex_color_scheme.dart @@ -1,3 +1,5 @@ +// ignore_for_file: sort_constructors_first + import 'dart:async'; import 'package:flex_seed_scheme/flex_seed_scheme.dart'; diff --git a/lib/src/flex_constants.dart b/lib/src/flex_constants.dart index e3715cbe6..801251048 100644 --- a/lib/src/flex_constants.dart +++ b/lib/src/flex_constants.dart @@ -171,6 +171,8 @@ const double kInputDecoratorRadius = 10; /// /// Value: 0x3D = 61 = 24% const int kNavigationBarIndicatorAlpha = 0x3D; + +/// Float version of the alpha value [kNavigationBarIndicatorAlpha]. const double kNavigationBarIndicatorAlphaFloat = 0x3D / 255; /// The width of a Material 2 Drawer. @@ -262,6 +264,8 @@ const double kTooltipRadius = 8; /// /// Value: 0x0D = 13 = 5% const int kFillColorAlphaLight = 0x0D; + +/// Float version of [kFillColorAlphaLight]. const double kFillColorAlphaLightFloat = 0x0D / 255; /// Fill color alpha value for [InputDecorator] used by FlexColorScheme @@ -269,6 +273,8 @@ const double kFillColorAlphaLightFloat = 0x0D / 255; /// /// Value: 0x14 = 20 = 8% const int kFillColorAlphaDark = 0x14; + +/// Float version of [kFillColorAlphaDark]. const double kFillColorAlphaDarkFloat = 0x14 / 255; /// Enabled border alpha value on border sides. @@ -280,6 +286,8 @@ const double kFillColorAlphaDarkFloat = 0x14 / 255; /// /// Value: 0xA7 = 167 = 65% const int kEnabledBorderAlpha = 0xA7; + +/// Float version of [kEnabledBorderAlpha]. const double kEnabledBorderAlphaFloat = 0xA7 / 255; /// The surface color alpha blend, for primary colored Chip background. @@ -288,6 +296,8 @@ const double kEnabledBorderAlphaFloat = 0xA7 / 255; /// /// Value: 0xCC = 204 = 80% const int kChipBackgroundAlphaBlend = 0xCC; + +/// Float version of [kChipBackgroundAlphaBlend]. const double kChipBackgroundAlphaBlendFloat = 0xCC / 255; /// The surface color alpha blend, for primary colored selected Chip background. @@ -296,6 +306,8 @@ const double kChipBackgroundAlphaBlendFloat = 0xCC / 255; /// /// Value: 0x96 = 150 = 59% const int kChipSelectedBackgroundAlphaBlend = 0x96; + +/// Float version of [kChipSelectedBackgroundAlphaBlend]. const double kChipSelectedBackgroundAlphaBlendFloat = 0x96 / 255; /// The onBackground primary alpha blend value for an unselected item, typically @@ -303,6 +315,8 @@ const double kChipSelectedBackgroundAlphaBlendFloat = 0x96 / 255; /// /// Value: 0x66 = 102 = 40% const int kUnselectedBackgroundPrimaryAlphaBlend = 0x66; + +/// Float version of [kUnselectedBackgroundPrimaryAlphaBlend]. const double kUnselectedBackgroundPrimaryAlphaBlendFloat = 0x66 / 255; /// The alpha value for an unselected item, typically an icon or text @@ -310,6 +324,8 @@ const double kUnselectedBackgroundPrimaryAlphaBlendFloat = 0x66 / 255; /// /// Value: 0xA5 = 165 = 65% const int kUnselectedAlphaBlend = 0xA5; + +/// Float version of [kUnselectedAlphaBlend]. const double kUnselectedAlphaBlendFloat = 0xA5 / 255; // The v7 new tinted interactions effects and disable constants start here. @@ -320,6 +336,8 @@ const double kUnselectedAlphaBlendFloat = 0xA5 / 255; /// /// Value: 0xB2 = 178 = 69.8% const int kTintHover = 0xB2; + +/// Float version of [kTintHover]. const double kTintHoverFloat = 0xB2 / 255; /// The amount of alpha based opacity used on standard hover effect. @@ -328,12 +346,16 @@ const double kTintHoverFloat = 0xB2 / 255; /// /// Value: 0x14 = 20 = 8% const int kAlphaHovered = 0x14; + +/// Float version of [kAlphaHovered]. const double kAlphaHoveredFloat = 0x14 / 255; /// The amount of alpha based opacity used on tinted hover effect. /// /// Value: 0x11 = 17 = 6.7% const int kAlphaTintedHovered = 0x11; + +/// Float version of [kAlphaTintedHovered]. const double kAlphaTintedHoveredFloat = 0x11 / 255; /// The amount of alpha blend used on tinted highlight effect that is blended @@ -341,6 +363,8 @@ const double kAlphaTintedHoveredFloat = 0x11 / 255; /// /// Value: 0xA5 = 165 = 65% const int kTintHighlight = 0xA5; + +/// Float version of [kTintHighlight]. const double kTintHighlightFloat = 0xA5 / 255; /// The amount of alpha based opacity used on standard highlight effect. @@ -349,12 +373,16 @@ const double kTintHighlightFloat = 0xA5 / 255; /// /// Value: 0x14 = 20 = 8% const int kAlphaHighlight = 0x14; + +/// Float version of [kAlphaHighlight]. const double kAlphaHighlightFloat = 0x14 / 255; /// The amount of alpha based opacity used on tinted highlight effect. /// /// Value: 0x0F = 15 = 5.9% const int kAlphaTintedHighlight = 0x0F; + +/// Float version of [kAlphaTintedHighlight]. const double kAlphaTintedHighlightFloat = 0x0F / 255; /// The amount of alpha blend used on tinted pressed effect that is blended @@ -362,6 +390,8 @@ const double kAlphaTintedHighlightFloat = 0x0F / 255; /// /// Value: 0xA5 = 165 = 65% const int kTintPressed = 0xA5; + +/// Float version of [kTintPressed]. const double kTintPressedFloat = 0xA5 / 255; /// The amount of alpha based opacity used on standard pressed effect. @@ -370,12 +400,16 @@ const double kTintPressedFloat = 0xA5 / 255; /// /// Value: 0x1F = 31 = 12.16% const int kAlphaPressed = 0x1F; + +/// Float version of [kAlphaPressed]. const double kAlphaPressedFloat = 0x1F / 255; /// The amount of alpha based opacity used on tinted pressed effect. /// /// Value: 0x10 = 16 = 6.3% const int kAlphaTintPressed = 0x10; + +/// Float version of [kAlphaTintPressed]. const double kAlphaTintPressedFloat = 0x10 / 255; /// The amount of alpha based opacity used on tinted input pressed effect, @@ -386,6 +420,8 @@ const double kAlphaTintPressedFloat = 0x10 / 255; /// /// Value: 0x19 = 25 = 10% = 0.1 const int kAlphaInputPressed = 0x19; + +/// Float version of [kAlphaInputPressed]. const double kAlphaInputPressedFloat = 0x19 / 255; /// The amount of alpha blend used on tinted splash effect that is blended @@ -393,6 +429,8 @@ const double kAlphaInputPressedFloat = 0x19 / 255; /// /// Value: 0xA5 = 165 = 65% const int kTintSplash = 0xA5; + +/// Float version of [kTintSplash]. const double kTintSplashFloat = 0xA5 / 255; /// The amount of alpha based opacity used on standard splash effect. @@ -401,12 +439,16 @@ const double kTintSplashFloat = 0xA5 / 255; /// /// Value: 0x1F = 31 = 12.16% const int kAlphaSplash = 0x1F; + +/// Float version of [kAlphaSplash]. const double kAlphaSplashFloat = 0x1F / 255; /// The amount of alpha based opacity used on tinted splash effect. /// /// Value: 0x10 = 16 = 6.3% const int kAlphaTintSplash = 0x10; + +/// Float version of [kAlphaTintSplash]. const double kAlphaTintSplashFloat = 0x10 / 255; /// The amount of alpha blend used on tinted focus effect that is blended @@ -414,6 +456,8 @@ const double kAlphaTintSplashFloat = 0x10 / 255; /// /// Value: 0xB2 = 178 = 70% const int kTintFocus = 0xB2; + +/// Float version of [kTintFocus]. const double kTintFocusFloat = 0xB2 / 255; /// The amount of alpha based opacity used on standard focus effect. @@ -422,12 +466,16 @@ const double kTintFocusFloat = 0xB2 / 255; /// /// Value: 0x1F = 31 = 12.16% const int kAlphaFocused = 0x1F; + +/// Float version of [kAlphaFocused]. const double kAlphaFocusedFloat = 0x1F / 255; /// The amount of alpha based opacity used on tinted focus effect. /// /// Value: 0x1C = 28 = 11% const int kAlphaTintFocused = 0x1C; + +/// Float version of [kAlphaTintFocused]. const double kAlphaTintFocusedFloat = 0x1C / 255; /// The amount of alpha blend used on tinted disabled effect that is blended @@ -435,6 +483,8 @@ const double kAlphaTintFocusedFloat = 0x1C / 255; /// /// Value: 0x66 = 102 = 40% const int kTintDisabled = 0x66; + +/// Float version of [kTintDisabled]. const double kTintDisabledFloat = 0x66 / 255; /// The amount of alpha based opacity used on tinted disabled effect. @@ -443,6 +493,8 @@ const double kTintDisabledFloat = 0x66 / 255; /// /// Value: 0x61 = 97 = 38.04% const int kAlphaDisabled = 0x61; + +/// Float version of [kAlphaDisabled]. const double kAlphaDisabledFloat = 0x61 / 255; /// An optional medium amount of alpha based opacity used on disabled @@ -452,6 +504,8 @@ const double kAlphaDisabledFloat = 0x61 / 255; /// /// Value: 0x52 = 82 = 32.16% const int kAlphaMediumDisabled = 0x52; + +/// Float version of [kAlphaMediumDisabled]. const double kAlphaMediumDisabledFloat = 0x52 / 255; /// An optional lower amount of alpha based opacity used on disabled components. @@ -460,6 +514,8 @@ const double kAlphaMediumDisabledFloat = 0x52 / 255; /// /// Value: 0x3D = 61 = 24% const int kAlphaLowDisabled = 0x3D; + +/// Float version of [kAlphaLowDisabled]. const double kAlphaLowDisabledFloat = 0x3D / 255; /// An optional lower amount of alpha based opacity used on tinted disabled @@ -470,6 +526,8 @@ const double kAlphaLowDisabledFloat = 0x3D / 255; /// /// Value: 0x1F = 31 = 12.16% const int kAlphaVeryLowDisabled = 0x1F; + +/// Float version of [kAlphaVeryLowDisabled]. const double kAlphaVeryLowDisabledFloat = 0x1F / 255; /// An optional ultra low amount of alpha based opacity used on tinted disabled @@ -479,6 +537,8 @@ const double kAlphaVeryLowDisabledFloat = 0x1F / 255; /// /// Value: 0x0A = 10 = 3.92%% const int kAlphaUltraLowDisabled = 0x0A; + +/// Float version of [kAlphaUltraLowDisabled]. const double kAlphaUltraLowDisabledFloat = 0x0A / 255; /// Default Color of disabled M2 Switch track color in M2 @@ -491,48 +551,64 @@ const Color kSwitchM2LightTrackColor = Color(0x52000000); /// /// Value: 0xDD = 221 = 86.67% const int kAlphaUnselect = 0xDD; + +/// Float version of [kAlphaUnselect]. const double kAlphaUnselectFloat = 0xDD / 255; /// Switch in M2 mode selected light mode alpha. /// /// Value: 0x70 = 112 = 43.92% const int kAlphaM2SwitchTrackLight = 0x70; + +/// Float version of [kAlphaM2SwitchTrackLight]. const double kAlphaM2SwitchTrackLightFloat = 0x70 / 255; /// Switch in M2 mode selected dark mode alpha. /// /// Value: 0x80 = 128 = 50.20% const int kAlphaM2SwitchTrackDark = 0x80; + +/// Float version of [kAlphaM2SwitchTrackDark]. const double kAlphaM2SwitchTrackDarkFloat = 0x80 / 255; /// Switch in M2 mode unselected light mode alpha. /// /// Value: 0x50 = 80 = 31.37% const int kAlphaM2SwitchUnselectTrackLight = 0x50; + +/// Float version of [kAlphaM2SwitchUnselectTrackLight]. const double kAlphaM2SwitchUnselectTrackLightFloat = 0x50 / 255; /// Switch in M2 mode unselected dark mode alpha. /// /// Value: 0x65 = 101 = 39.61% const int kAlphaM2SwitchUnselectTrackDark = 0x65; + +/// Float version of [kAlphaM2SwitchUnselectTrackDark]. const double kAlphaM2SwitchUnselectTrackDarkFloat = 0x65 / 255; /// Switch in M3 mode unselected light mode alpha. /// /// Value: 0x33 = 51 = 20.00% const int kAlphaM3SwitchUnselectTrackLight = 0x33; + +/// Float version of [kAlphaM3SwitchUnselectTrackLight]. const double kAlphaM3SwitchUnselectTrackLightFloat = 0x33 / 255; /// Switch in M3 mode unselected dark mode alpha. /// /// Value: 0x44 = 68 = 26.67% const int kAlphaM3SwitchUnselectTrackDark = 0x44; + +/// Float version of [kAlphaM3SwitchUnselectTrackDark]. const double kAlphaM3SwitchUnselectTrackDarkFloat = 0x44 / 255; /// Tick mark alpha for Slider and RangeSlider. /// /// Value: 0x8A = 138 = 54.12% const int kAlphaSliderTickMark = 0x8A; + +/// Float version of [kAlphaSliderTickMark]. const double kAlphaSliderTickMarkFloat = 0x8A / 255; /// Input decorator light color decorator background color, hover mode @@ -590,36 +666,48 @@ const int kLoDarkTextBlend = 15; /// /// Value: 0xD8 = 85% const int kHiLightTextAlpha = 0xD8; + +/// Float version of [kHiLightTextAlpha]. const double kHiLightTextAlphaFloat = 0xD8 / 255; /// High blended dark TextTheme alpha value /// /// Value: 0xE2 = 92% const int kHiDarkTextAlpha = 0xE2; + +/// Float version of [kHiDarkTextAlpha]. const double kHiDarkTextAlphaFloat = 0xE2 / 255; /// Medium blended light TextTheme alpha value /// /// Value: 0xF4 = 96% const int kMedLightTextAlpha = 0xF4; + +/// Float version of [kMedLightTextAlpha]. const double kMedLightTextAlphaFloat = 0xF4 / 255; /// Medium blended dark TextTheme alpha value /// /// Value: 0xFF = 100% const int kMedDarkTextAlpha = 0xFF; + +/// Float version of [kMedDarkTextAlpha]. const double kMedDarkTextAlphaFloat = 0xFF / 255; /// Low blended light TextTheme alpha value /// /// Value: 0xFF = 100% const int kLoLightTextAlpha = 0xFF; + +/// Float version of [kLoLightTextAlpha]. const double kLoLightTextAlphaFloat = 0xFF / 255; /// Low blended dark TextTheme alpha value /// /// Value: 0xFF = 100% const int kLoDarkTextAlpha = 0xFF; + +/// Float version of [kLoDarkTextAlpha]. const double kLoDarkTextAlphaFloat = 0xFF / 255; // Primary TextTheme @@ -658,36 +746,48 @@ const int kLoDarkPrimTextBlend = 7; /// /// Value: 0xD8 = 85% const int kHiLightPrimTextAlpha = 0xD8; + +/// Float version of [kHiLightPrimTextAlpha]. const double kHiLightPrimTextAlphaFloat = 0xD8 / 255; /// High blended dark PrimaryTextTheme alpha value /// /// Value: 0xE5 = 90% const int kHiDarkPrimTextAlpha = 0xE5; + +/// Float version of [kHiDarkPrimTextAlpha]. const double kHiDarkPrimTextAlphaFloat = 0xE5 / 255; /// Medium blended light PrimaryTextTheme alpha value /// /// Value: 0xF2 = 95% const int kMedLightPrimTextAlpha = 0xF2; + +/// Float version of [kMedLightPrimTextAlpha]. const double kMedLightPrimTextAlphaFloat = 0xF2 / 255; /// Medium blended dark PrimaryTextTheme alpha value /// /// Value: 0xFF = 100% const int kMedDarkPrimTextAlpha = 0xFF; + +/// Float version of [kMedDarkPrimTextAlpha]. const double kMedDarkPrimTextAlphaFloat = 0xFF / 255; /// Low blended light PrimaryTextTheme alpha value /// /// Value: 0xFF = 100% const int kLoLightPrimTextAlpha = 0xFF; + +/// Float version of [kLoLightPrimTextAlpha]. const double kLoLightPrimTextAlphaFloat = 0xFF / 255; /// Low blended dark PrimaryTextTheme alpha value /// /// Value: 0xFF = 100% const int kLoDarkPrimTextAlpha = 0xFF; + +/// Float version of [kLoDarkPrimTextAlpha]. const double kLoDarkPrimTextAlphaFloat = 0xFF / 255; // Version 7.2 new const properties diff --git a/lib/src/flex_scheme_color.dart b/lib/src/flex_scheme_color.dart index c766dadb1..0959797b1 100644 --- a/lib/src/flex_scheme_color.dart +++ b/lib/src/flex_scheme_color.dart @@ -248,6 +248,7 @@ class FlexSchemeColor with Diagnosticable { /// [FlexColor.materialLightError] or [FlexColor.materialDarkError] /// or as input value for [error] if not provided and computes /// [errorContainer]. If either value is passed in they are used as given. + // ignore: sort_constructors_first factory FlexSchemeColor.from({ required Color primary, Color? primaryContainer, diff --git a/lib/src/flex_scheme_on_colors.dart b/lib/src/flex_scheme_on_colors.dart index 87cb71bd0..4c9046963 100644 --- a/lib/src/flex_scheme_on_colors.dart +++ b/lib/src/flex_scheme_on_colors.dart @@ -129,6 +129,7 @@ class FlexSchemeOnColors with Diagnosticable { /// /// The factory can also alpha blend the onColor, with each color using an /// optionally provided alpha blend level, that defaults to 0. + // ignore: sort_constructors_first factory FlexSchemeOnColors.from({ bool? useMaterial3, required Color primary, diff --git a/lib/src/flex_scheme_surface_colors.dart b/lib/src/flex_scheme_surface_colors.dart index 26bc503e2..efedea22f 100644 --- a/lib/src/flex_scheme_surface_colors.dart +++ b/lib/src/flex_scheme_surface_colors.dart @@ -173,6 +173,7 @@ class FlexSchemeSurfaceColors with Diagnosticable { /// The surface colors returned by this factory can also be used to make /// branded surface colors for Flutter's standard [ColorScheme], it does /// not have to be used exclusively by [FlexColorScheme]. + // ignore: sort_constructors_first factory FlexSchemeSurfaceColors.blend({ /// Controls if we create surface colors for light or dark surfaces. final Brightness brightness = Brightness.light, diff --git a/test/flex_color_scheme_region_widget_test.dart b/test/flex_color_scheme_region_widget_test.dart index 1ed97e0de..b654b6c79 100644 --- a/test/flex_color_scheme_region_widget_test.dart +++ b/test/flex_color_scheme_region_widget_test.dart @@ -34,13 +34,13 @@ void main() { } class MyWidget extends StatelessWidget { - final ColorScheme scheme; - const MyWidget({ super.key, required this.scheme, }); + final ColorScheme scheme; + @override Widget build(BuildContext context) { debugDefaultTargetPlatformOverride = null;