From 80c097ac1616e8bbcb0b8ca7ce862aebe4bc3ed1 Mon Sep 17 00:00:00 2001 From: rydmike Date: Thu, 12 Dec 2024 00:21:10 +0200 Subject: [PATCH 01/24] Add changelog stub entry for v3-7-0 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6a35b0..9f0f73a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to the **FlexColorPicker** package are documented in this file. +## 3.7.0 WIP/DRAFT + +**Dec 12, 2024** + +**PACKAGE** + +* First prep for Flutter 3.27.0 update with new Color features that supports wide gamut. In total, 243 deprecations will have to be replaced with the new Color features. + + ## 3.6.0 **September 25, 2024** From 06f7d192bcbc8c385fef4f7d7d81e325de0a39d7 Mon Sep 17 00:00:00 2001 From: rydmike Date: Thu, 12 Dec 2024 00:21:22 +0200 Subject: [PATCH 02/24] Update version info --- example/lib/demo/utils/app.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/lib/demo/utils/app.dart b/example/lib/demo/utils/app.dart index 295a8c0..509a2a1 100644 --- a/example/lib/demo/utils/app.dart +++ b/example/lib/demo/utils/app.dart @@ -9,14 +9,14 @@ class App { // Web demo with inside the app. Shown on the start screen in the demo, // so people testing it don't have to ask. Also info for the About screen. static const String appName = 'FlexColorPicker'; - static const String version = '3.6.0'; + static const String version = '3.7.0-beta'; static const String packageVersion = 'FlexColorPicker package $version'; static final Uri packageUri = Uri( scheme: 'https', host: 'pub.dev', path: 'packages/flex_color_picker', ); - static const String flutterVersion = 'Channel stable 3.24.3 (canvaskit)'; + static const String flutterVersion = 'Channel stable 3.27.0 (canvaskit)'; static const String copyright = '© 2020 - 2024'; static const String author = 'Mike Rydstrom'; static const String license = 'BSD 3-Clause License'; From 22c6f53dccf6bdd887907cacfc1a547e1346004d Mon Sep 17 00:00:00 2001 From: rydmike Date: Thu, 12 Dec 2024 00:22:15 +0200 Subject: [PATCH 03/24] Bump versions --- example/pubspec.yaml | 4 ++-- pubspec.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 885e229..22e245b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,10 +1,10 @@ name: color_picker_example description: Two examples of how to use the FlexColorPicker package. -version: 3.6.0 +version: 3.7.0 publish_to: 'none' environment: sdk: '>=2.19.0 <4.0.0' - flutter: '>=3.22.0' + flutter: '>=3.27.0' dependencies: # https://pub.dev/packages/flex_color_picker diff --git a/pubspec.yaml b/pubspec.yaml index 2db5304..c140250 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flex_color_picker description: A customizable Flutter primary, accent and custom color picker. Includes an optional HSV wheel color picker. -version: 3.6.0 +version: 3.7.0 homepage: https://github.com/rydmike/flex_color_picker repository: https://github.com/rydmike/flex_color_picker issue_tracker: https://github.com/rydmike/flex_color_picker/issues @@ -25,7 +25,7 @@ topics: environment: sdk: '>=3.0.0 <4.0.0' - flutter: '>=3.2.0' + flutter: '>=3.27.0' dependencies: # FlexSeedScheme package, by Mike Rydstrom, rydmike.com (@rydmike). From 36f6dbc7d1424611427301b5e3d162057e4ddf21 Mon Sep 17 00:00:00 2001 From: rydmike Date: Thu, 12 Dec 2024 00:22:40 +0200 Subject: [PATCH 04/24] Updating linting with new available rules --- all_lint_rules.yaml | 37 ++++++- analysis_options.yaml | 247 ++++++++++++++++++++++++++++++++---------- 2 files changed, 223 insertions(+), 61 deletions(-) diff --git a/all_lint_rules.yaml b/all_lint_rules.yaml index 05a1af2..4e31697 100644 --- a/all_lint_rules.yaml +++ b/all_lint_rules.yaml @@ -1,6 +1,22 @@ -# A list of all linter rules. Up to date auto generated list of all -# lint rules can be found here: -# https://dart-lang.github.io/linter/lints/options/options.html +# A list of all linter rules. +# Expected by rydmike analysis_options: V2.3.0 +# +# Up-to-date auto generated list: https://dart.dev/tools/linter-rules/all +# +# The list below has removed ALL deprecated lint rules. These following were still included +# in the above list of all lint rules, but are deprecated and should NOT be used: +# +# - avoid_returning_null_for_future (Deprecated) +# - iterable_contains_unrelated_type (Deprecated) +# - list_remove_unrelated_type (Deprecated) +# - always_require_non_null_named_parameters (Deprecated) +# - avoid_returning_null (Deprecated) +# +# Version 2.3.0 removed the following deprecated rules: +# - avoid_unstable_final_fields +# - unnecessary_getters_settersinvariant_booleans +# - unsafe_html +# linter: rules: - always_declare_return_types @@ -9,6 +25,7 @@ linter: - always_specify_types - always_use_package_imports - annotate_overrides + - annotate_redeclares - avoid_annotating_with_dynamic - avoid_bool_literals_in_conditional_expressions - avoid_catches_without_on_clauses @@ -22,6 +39,7 @@ linter: - avoid_field_initializers_in_const_classes - avoid_final_parameters - avoid_function_literals_in_foreach_calls + - avoid_futureor_void - avoid_implementing_value_types - avoid_init_to_null - avoid_js_rounded_ints @@ -69,6 +87,7 @@ linter: - directives_ordering - discarded_futures - do_not_use_environment + - document_ignores - empty_catches - empty_constructor_bodies - empty_statements @@ -81,7 +100,7 @@ linter: - implicit_call_tearoffs - implicit_reopen - invalid_case_patterns - - iterable_contains_unrelated_type + - invalid_runtime_check_with_js_interop_types - join_return_with_assignment - leading_newlines_in_multiline_strings - library_annotations @@ -89,9 +108,9 @@ linter: - library_prefixes - library_private_types_in_public_api - lines_longer_than_80_chars - - list_remove_unrelated_type - literal_only_boolean_expressions - matching_super_parameters + - missing_code_block_language_in_doc_comment - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_default_cases @@ -101,11 +120,14 @@ linter: - no_literal_bool_comparisons - no_logic_in_create_state - no_runtimeType_toString + - no_self_assignments + - no_wildcard_variable_uses - non_constant_identifier_names - noop_primitive_operations - null_check_on_nullable_type_parameter - null_closures - omit_local_variable_types + - omit_obvious_local_variable_types - one_member_abstracts - only_throw_errors - overridden_fields @@ -164,6 +186,7 @@ linter: - sort_constructors_first - sort_pub_dependencies - sort_unnamed_constructors_first + - specify_nonobvious_local_variable_types - test_types_in_equals - throw_in_finally - tighten_type_of_initializing_formals @@ -171,6 +194,7 @@ linter: - type_init_formals - type_literal_in_constant_pattern - unawaited_futures + - unintended_html_in_doc_comment - unnecessary_await_in_return - unnecessary_brace_in_string_interps - unnecessary_breaks @@ -181,6 +205,7 @@ linter: - unnecessary_lambdas - unnecessary_late - unnecessary_library_directive + - unnecessary_library_name - unnecessary_new - unnecessary_null_aware_assignments - unnecessary_null_aware_operator_on_extension_on_nullable @@ -197,7 +222,6 @@ linter: - unnecessary_to_list_in_spreads - unreachable_from_main - unrelated_type_equality_checks - - unsafe_html - use_build_context_synchronously - use_colored_box - use_decorated_box @@ -217,5 +241,6 @@ linter: - use_super_parameters - use_test_throws_matchers - use_to_and_as_if_applicable + - use_truncating_division - valid_regexps - void_checks \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml index c4d0305..a7e3cdc 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,27 +1,27 @@ -# RydMike LINTER Preferences v2.0.1 +# 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 # # We include and activate all lint rules, later below we disable the not used or desired ones. # You can find a list of all lint rules to put in your all_lint_rules.yaml file here: -# https://dart-lang.github.io/linter/lints/options/options.html +# https://dart.dev/tools/linter-rules/all # -# For a full comparison of all lint rules settings in rule styles listed below, please see this +# 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 # -# The version used for comparing setting with other linters for the settings -# that are turned OFF here, or have a quick placeholder for turning it OFF, are -# as follows: +# Versions used for comparison: +# TODO(rydmike): Update the used comparisons to their latest version. # -# Core v2.1.0 : https://pub.dev/packages/lints -# Recommended v2.0.0 : https://pub.dev/packages/lints -# Flutter Lints v2.1.0 : https://pub.dev/packages/flutter_lints +# 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 # 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 v1.8.2 : https://pub.dev/packages/lint -# VG Analysis v3.0.0 : https://pub.dev/packages/very_good_analysis -# RydMike v2.0.1 : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c +# 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 # include: all_lint_rules.yaml analyzer: @@ -32,8 +32,7 @@ analyzer: - "bin/cache/**" - "lib/generated_plugin_registrant.dart" - # For more information see: - # https://dart.dev/guides/language/analysis-options#enabling-additional-type-checks + # For more information see: https://dart.dev/tools/analysis language: strict-casts: true strict-inference: true @@ -41,7 +40,7 @@ analyzer: errors: # Without ignore here, we cause import of all_lint_rules to warn, because some rules conflict. - # We explicitly enabled even conflicting rules and are fixing the conflicts in this file. + # We explicitly enable conflicting rules and are fixing the conflicts in this file. # Put it to warning temporarily if you need to troubleshoot lint rule settings. included_file_warning: ignore @@ -51,13 +50,22 @@ analyzer: # Treat missing returns as an error, not as a hint or a warning. missing_return: error + # A record literal with exactly one positional field requires a trailing comma. + record_literal_one_positional_no_trailing_comma: error + + # Invocation collection methods with arguments of unrelated types. + collection_methods_unrelated_type: warning + + # Invocation of equality operator == with references of unrelated types. + unrelated_type_equality_checks: warning + # Allow self-reference to deprecated members. This is done because otherwise we have # to annotate every member in every test, assert, etc. when we deprecate something. - deprecated_member_use_from_same_package: ignore + # deprecated_member_use_from_same_package: ignore # DON'T assign new values to parameters of methods or functions. # - # https://dart-lang.github.io/linter/lints/parameter_assignments.html + # https://dart.dev/tools/linter-rules/parameter_assignments.html # # Treats assigning new values to a parameter as a warning. We would almost like to set this # to an error. However, this warning rule, or even more so if you set it to be an error, may @@ -68,7 +76,7 @@ analyzer: # safety/fallback assignment. For that use case, you have to add a local rule override. With # null-safety, the need for this kind of null check and re-assignment to default if null, # is rarely needed. Considering the comment in: - # https://dart-lang.github.io/linter/lints/parameter_assignments.html: + # https://dart.dev/tools/linter-rules/parameter_assignments.html: # "Assigning new values to parameters is generally a bad practice unless an operator # such as ??= is used. Otherwise, arbitrarily reassigning parameters is usually a mistake." # One might even think the rule would allow using the ??= operator, but it does not. For now, @@ -89,7 +97,7 @@ linter: # ALWAYS separate the control structure expression from its statement. # - # https://dart-lang.github.io/linter/lints/always_put_control_body_on_new_line.html + # https://dart.dev/tools/linter-rules/always_put_control_body_on_new_line.html # # This sometimes makes things more unclear when one line is enough. Also, single line if:s are # fine and also recommended in Effective Dart "DO format your code using dartfmt". @@ -109,7 +117,7 @@ linter: # ALWAYS specify @required on named parameter before other named parameters. # - # https://dart-lang.github.io/linter/lints/always_put_required_named_parameters_first.html + # https://dart.dev/tools/linter-rules/always_put_required_named_parameters_first.html # # Conflicts with the convention used by Flutter, which puts `Key key` first # and `@required Widget child` last. @@ -128,7 +136,7 @@ linter: # ALWAYS specify type annotations. # - # https://dart-lang.github.io/linter/lints/always_specify_types.html + # https://dart.dev/tools/linter-rules/always_specify_types.html # # Avoid var when specifying that a type is unknown and short-hands that elude type annotations. Use # dynamic if you are being explicit that the type is unknown. Use Object if you are being explicit @@ -140,7 +148,7 @@ linter: # For devs used to more relaxed or no type declaration, it is probably the other way around. # This rule is, of course, also in conflict with some other lint rules. Most notably, it # violates Effective Dart "AVOID type annotating initialized local variables". - # https://dart-lang.github.io/linter/lints/omit_local_variable_types.html + # https://dart.dev/tools/linter-rules/omit_local_variable_types.html # Which we find to be a strange rule, the package lint agrees with the statement that # "Types for local variables may improve readability" and keeps that avoid rule disabled. # @@ -173,11 +181,13 @@ linter: # Lint disabled : https://pub.dev/packages/lint # VG Analysis disabled : https://pub.dev/packages/very_good_analysis # RydMike enabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + # PACKAGE: enabled : Enable rule by commenting it below, do this for PACKAGES. + # APPLICATION: disabled : Disable rule by not commenting the row below, do this for APPS. # always_specify_types: false # ALWAYS use package imports for files in lib/. # - # https://dart-lang.github.io/linter/lints/always_use_package_imports.html + # https://dart.dev/tools/linter-rules/always_use_package_imports.html # # This rule conflicts with `prefer_relative_imports` so we turn it OFF. # We are still conflicted about which version to use, keeping it this way for now. Support @@ -205,14 +215,14 @@ 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 disabled : https://pub.dev/packages/lint + # Lint enabled : https://pub.dev/packages/lint # VG Analysis enabled : https://pub.dev/packages/very_good_analysis # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c always_use_package_imports: false # AVOID annotating with dynamic when not required. # - # https://dart-lang.github.io/linter/lints/avoid_annotating_with_dynamic.html + # https://dart.dev/tools/linter-rules/avoid_annotating_with_dynamic.html # # Violates Effective Dart "PREFER annotating with dynamic instead of letting inference fail", it # also conflicts with strong mode disabling `implicit-dynamic`. Turning it OFF. @@ -232,7 +242,7 @@ linter: # AVOID catches without on clauses. # - # https://dart-lang.github.io/linter/lints/avoid_catches_without_on_clauses.html + # 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 @@ -254,7 +264,7 @@ linter: # AVOID defining a class that contains only static members. # - # https://dart-lang.github.io/linter/lints/avoid_classes_with_only_static_members.html + # https://dart.dev/tools/linter-rules/avoid_classes_with_only_static_members.html # # Creating classes with the sole purpose of providing utility, or otherwise static methods, is # discouraged in effective Dart. Dart allows functions to exist outside of classes for this @@ -286,7 +296,7 @@ linter: # AVOID declaring parameters as final. # - # https://dart-lang.github.io/linter/lints/avoid_final_parameters.html + # https://dart.dev/tools/linter-rules/avoid_final_parameters.html # # Declaring parameters as final can lead to unnecessarily verbose code, # especially when using the "parameter_assignments" rule. @@ -302,14 +312,14 @@ 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 disabled : https://pub.dev/packages/lint - # VG Analysis disabled : https://pub.dev/packages/very_good_analysis + # Lint enabled : https://pub.dev/packages/lint + # VG Analysis enabled : https://pub.dev/packages/very_good_analysis # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c avoid_final_parameters: false # AVOID positional boolean parameters. # - # https://dart-lang.github.io/linter/lints/avoid_positional_boolean_parameters.html + # https://dart.dev/tools/linter-rules/avoid_positional_boolean_parameters.html # # Positional boolean parameters are considered a bad practice because they are very ambiguous. # Using named boolean parameters is much more readable because it inherently describes @@ -337,14 +347,14 @@ linter: # 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 enabled : https://pub.dev/packages/lint + # Lint disabled : https://pub.dev/packages/lint # VG Analysis enabled : https://pub.dev/packages/very_good_analysis # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c avoid_positional_boolean_parameters: false # AVOID print calls in production code. # - # https://dart-lang.github.io/linter/lints/avoid_print.html + # https://dart.dev/tools/linter-rules/avoid_print.html # # Our default is to have this rule enabled. # @@ -372,7 +382,7 @@ linter: # AVOID redundant argument values. # - # https://dart-lang.github.io/linter/lints/avoid_redundant_argument_values.html + # https://dart.dev/tools/linter-rules/avoid_redundant_argument_values.html # # Using redundant (default) argument values can be useful for in-code documentation # purposes and also handy as a template when trying different settings in Flutter. It is often @@ -400,7 +410,7 @@ linter: # AVOID annotating types for function expression parameters. # - # https://dart-lang.github.io/linter/lints/avoid_catches_without_on_clauses.html + # https://dart.dev/tools/linter-rules/avoid_catches_without_on_clauses.html # # Annotating types for function expression parameters is usually unnecessary because the # parameter types can almost always be inferred from the context, thus making the practice redundant. @@ -426,7 +436,7 @@ linter: # DO Use the cascading style when successively invoking methods on the same reference. # - # https://dart-lang.github.io/linter/lints/cascade_invocations.html + # https://dart.dev/tools/linter-rules/cascade_invocations.html # # We disable this rule, just a personal preference, using them is fine though, # but let's not enforce it. @@ -446,7 +456,7 @@ linter: # DO invoke close on instances of dart.core.Sink. # - # https://dart-lang.github.io/linter/lints/close_sinks.html + # https://dart.dev/tools/linter-rules/close_sinks.html # # Disabling it, may generate false positives. https://github.com/dart-lang/linter/issues/1381. # @@ -461,11 +471,35 @@ linter: # 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 - #close_sinks: false + close_sinks: false + + # AVOID using deprecated elements from within the package in which they are declared. + # + # https://dart.dev/tools/linter-rules/deprecated_member_use_from_same_package + # + # Elements that are annotated with @Deprecated should not be referenced from within the + # package in which they are declared. + # + # RydMike: In packages and especially in public packages, it is often useful to deprecate a + # member, but keep it available and functional until the deprecated member is completley + # removed. We thus need to reference it in code and doc comments. + # + # 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 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 + # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + deprecated_member_use_from_same_package: false # DO reference all public properties in debug method implementations. # - # https://dart-lang.github.io/linter/lints/diagnostic_describe_all_properties.html + # 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 @@ -486,9 +520,54 @@ linter: # APPLICATION: disabled : With false value. (Default, assume we are making an app most of the time.) diagnostic_describe_all_properties: false + # DO NOT use environment declared variables. + # + # https://dart.dev/tools/linter-rules/do_not_use_environment + # + # Using values derived from the environment at compile-time, creates hidden global state + # and makes applications hard to understand and maintain. + # DON’T use fromEnvironment or hasEnvironment factory constructors. + # + # RydMike: There are appropriate times to use the environment, e.g. in tests and build logic + # + # 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 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 + # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + do_not_use_environment: false + + # DO document lint ignores. + # + # https://dart.dev/tools/linter-rules/document_ignores + # + # 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. + # + # 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 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 + # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + document_ignores: false + # DO Use Flutter TO-DO format. # - # https://dart-lang.github.io/linter/lints/flutter_style_todos.html + # https://dart.dev/tools/linter-rules/flutter_style_todos.html # # Use Flutter-style todos with GitHub username. Useful if you are coding in a # larger team, if not, you may also consider turning off the rule by removing @@ -509,7 +588,7 @@ linter: # AVOID lines longer than 80 characters # - # https://dart-lang.github.io/linter/lints/lines_longer_than_80_chars.html + # https://dart.dev/tools/linter-rules/lines_longer_than_80_chars.html # # Using this rule will sometimes force a line of 81 characters to be split in two. # As long as we try to respect the 80-character limit, going slightly above is fine. @@ -536,9 +615,29 @@ linter: # APPLICATION: disabled : With false value. (When/if short lines become problematic. We sometimes like 100 chars.) # lines_longer_than_80_chars: false + # DO use super parameter names that match their corresponding super constructor’s + # parameter names. + # + # https://dart.dev/tools/linter-rules/matching_super_parameters + # + # Blocked by issue: https://github.com/dart-lang/language/issues/2509 + # + # 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 disabled : 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 disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + matching_super_parameters: false + # DO define default behavior outside switch statements. # - # https://dart-lang.github.io/linter/lints/no_default_cases.html + # https://dart.dev/tools/linter-rules/no_default_cases.html # # An experimental lint rule maturity wise. I enabled it, it seems to work well. # Remove the comment below if it is causing issues. @@ -558,7 +657,7 @@ linter: # CONSIDER omitting type annotations for local variables. # - # https://dart-lang.github.io/linter/lints/omit_local_variable_types.html + # https://dart.dev/tools/linter-rules/omit_local_variable_types.html # # Conflicts with 'always_specify_types' that is used, so then we can't have this rule either, # besides we like being verbose and specific. Why and when would omitting the type for local @@ -577,9 +676,30 @@ linter: # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c omit_local_variable_types: false + # CONSIDER omitting obvious type annotations for local variables. + # + # https://dart.dev/tools/linter-rules/omit_obvious_local_variable_types + # + # Conflicts with 'always_specify_types' that is used, so then we can't have this rule either, + # besides we like being verbose and specific. Why and when would omitting the type for local + # variables be a good thing anyway, be specific, is our take on this. + # + # 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 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 + # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + omit_obvious_local_variable_types: false + # PREFER asserts with a message string. # - # https://dart-lang.github.io/linter/lints/prefer_asserts_with_message.html + # https://dart.dev/tools/linter-rules/prefer_asserts_with_message.html # # When assertions fail, it's not always simple to understand why. Adding a message to the # assert function helps the developer to understand why the AssertionError occurs. @@ -612,7 +732,7 @@ linter: # PREFER to define constructors, instead of static methods to create instances. # - # https://dart-lang.github.io/linter/lints/prefer_constructors_over_static_methods.html + # https://dart.dev/tools/linter-rules/prefer_constructors_over_static_methods.html # # Dart has named constructors. Static methods in other languages (java) are a workaround to # not having named constructors. @@ -642,12 +762,12 @@ linter: # DO use double quotes where they wouldn't require additional escapes. # - # https://dart-lang.github.io/linter/lints/prefer_double_quotes.html + # https://dart.dev/tools/linter-rules/prefer_double_quotes.html # # This rule is mostly about what style you want to use and enforce, if any. # It of course conflicts with rule: # `prefer_single_quotes` : "DO use single quotes where they wouldn't require additional escapes." - # https://dart-lang.github.io/linter/lints/prefer_single_quotes.html + # https://dart.dev/tools/linter-rules/prefer_single_quotes.html # # For us single quotes are easier to type. On our ISO keyboards it is next to Enter key, and # we don't need the Shift plus the far to reach nr 2 key on R1 to type it. Also, we don't think @@ -675,7 +795,7 @@ linter: # CONSIDER using => for short members whose body is a single return statement. # - # https://dart-lang.github.io/linter/lints/prefer_expression_function_bodies.html + # 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 @@ -697,7 +817,7 @@ linter: # DO prefer declaring parameters as final if they are not reassigned in the function body. # - # https://dart-lang.github.io/linter/lints/prefer_final_parameters.html + # https://dart.dev/tools/linter-rules/prefer_final_parameters.html # # Declaring parameters as final when possible is a good practice because it helps # avoid accidental reassignments. @@ -727,7 +847,7 @@ linter: # DO use int literals rather than the corresponding double literal. # - # https://dart-lang.github.io/linter/lints/prefer_int_literals.html + # 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 @@ -750,14 +870,14 @@ linter: # DO document all public members. # - # https://dart-lang.github.io/linter/lints/public_member_api_docs.html + # https://dart.dev/tools/linter-rules/public_member_api_docs.html # # All non-overriding public members should be documented with /// doc-style comments. # Not necessary for an app or the examples in a pub.dev package. I always enable this for # public packages. # # NOTE: There is also the lint rule "package_api_docs", that is enabled as well via all being enabled. - # https://dart-lang.github.io/linter/lints/package_api_docs.html + # https://dart.dev/tools/linter-rules/package_api_docs.html # "DO provide doc comments for all public APIs.", is what it is supposed to do, but only for # packages. However, if we turn OFF the rule "public_member_api_docs", then the # "package_api_docs" offers no warnings on missing API doc comments alone. So our conclusion @@ -777,13 +897,13 @@ linter: # 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, # fits in a single line. # - # https://dart-lang.github.io/linter/lints/require_trailing_commas.html + # https://dart.dev/tools/linter-rules/require_trailing_commas.html # # This rule forces commas even in places where it just adds extra lines, that # adds little value. There is also not a bulk dart fix for it: @@ -830,7 +950,7 @@ linter: # DON'T use final for local variables. # - # https://dart-lang.github.io/linter/lints/unnecessary_final.html + # https://dart.dev/tools/linter-rules/unnecessary_final.html # # Incompatible with `prefer_final_locals` that we want because having immutable local variables when # applicable makes larger functions more predictable and easier to reason about, so we @@ -848,3 +968,20 @@ linter: # VG Analysis disabled : https://pub.dev/packages/very_good_analysis # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c unnecessary_final: false + + # DO use DecoratedBox when a Container has only a Decoration. + # + # Not used because of this issue https://github.com/dart-lang/linter/issues/3286 + # + # 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 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 + # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c + use_decorated_box: false \ No newline at end of file From a8eecab82a38a70cb8cffae7d5dd9e1fcb4774d4 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 12:27:21 +0200 Subject: [PATCH 05/24] Pubspec lock bump --- example/pubspec.lock | 56 ++++++++++++++++++++++---------------------- pubspec.lock | 54 +++++++++++++++++++++--------------------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index d3c155c..b44ec38 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,23 +5,23 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 + sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" url: "https://pub.dev" source: hosted - version: "72.0.0" + version: "76.0.0" _macros: dependency: transitive description: dart source: sdk - version: "0.3.2" + version: "0.3.3" analyzer: dependency: transitive description: name: analyzer - sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 + sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" url: "https://pub.dev" source: hosted - version: "6.7.0" + version: "6.11.0" args: dependency: transitive description: @@ -66,10 +66,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" convert: dependency: transitive description: @@ -124,7 +124,7 @@ packages: path: ".." relative: true source: path - version: "3.6.0" + version: "3.7.0" flex_seed_scheme: dependency: transitive description: @@ -232,18 +232,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.7" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.8" leak_tracker_testing: dependency: transitive description: @@ -264,10 +264,10 @@ packages: dependency: transitive description: name: macros - sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" + sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" url: "https://pub.dev" source: hosted - version: "0.1.2-main.4" + version: "0.1.3-main.0" matcher: dependency: transitive description: @@ -448,7 +448,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_map_stack_trace: dependency: transitive description: @@ -477,10 +477,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.0" state_notifier: dependency: transitive description: @@ -501,10 +501,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" term_glyph: dependency: transitive description: @@ -517,26 +517,26 @@ packages: dependency: "direct dev" description: name: test - sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e" + sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f" url: "https://pub.dev" source: hosted - version: "1.25.7" + version: "1.25.8" test_api: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.3" test_core: dependency: transitive description: name: test_core - sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696" + sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d" url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.5" typed_data: dependency: transitive description: @@ -621,10 +621,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.3.0" watcher: dependency: transitive description: @@ -683,4 +683,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.5.0 <4.0.0" - flutter: ">=3.24.0" + flutter: ">=3.27.0" diff --git a/pubspec.lock b/pubspec.lock index 5f1e220..3e1a7a0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,23 +5,23 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 + sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" url: "https://pub.dev" source: hosted - version: "72.0.0" + version: "76.0.0" _macros: dependency: transitive description: dart source: sdk - version: "0.3.2" + version: "0.3.3" analyzer: dependency: transitive description: name: analyzer - sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 + sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" url: "https://pub.dev" source: hosted - version: "6.7.0" + version: "6.11.0" args: dependency: transitive description: @@ -66,10 +66,10 @@ packages: dependency: "direct dev" description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" convert: dependency: transitive description: @@ -180,18 +180,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.7" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.8" leak_tracker_testing: dependency: transitive description: @@ -212,10 +212,10 @@ packages: dependency: transitive description: name: macros - sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" + sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" url: "https://pub.dev" source: hosted - version: "0.1.2-main.4" + version: "0.1.3-main.0" matcher: dependency: transitive description: @@ -332,7 +332,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_map_stack_trace: dependency: transitive description: @@ -361,10 +361,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.0" stream_channel: dependency: transitive description: @@ -377,10 +377,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" term_glyph: dependency: transitive description: @@ -393,26 +393,26 @@ packages: dependency: "direct dev" description: name: test - sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e" + sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f" url: "https://pub.dev" source: hosted - version: "1.25.7" + version: "1.25.8" test_api: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.3" test_core: dependency: transitive description: name: test_core - sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696" + sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d" url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.5" typed_data: dependency: transitive description: @@ -433,10 +433,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.3.0" watcher: dependency: transitive description: @@ -487,4 +487,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.4.0 <4.0.0" - flutter: ">=3.22.0" + flutter: ">=3.27.0" From 7416194e57ef2b52c23dc961c0f5944d72967d38 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 12:28:01 +0200 Subject: [PATCH 06/24] Lint: Doc comment add lang info --- lib/src/color_tools.dart | 2 +- lib/src/models/color_picker_copy_paste_behavior.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/color_tools.dart b/lib/src/color_tools.dart index 0d51904..2d7eb98 100644 --- a/lib/src/color_tools.dart +++ b/lib/src/color_tools.dart @@ -22,7 +22,7 @@ import 'functions/picker_functions.dart'; /// setup a function that modifies them as needed in your app, /// something simple like this may be all you need: /// -/// ``` +/// ```dart /// void main() { /// translateColorNames(); /// runApp(const ColorPickerDemo()); diff --git a/lib/src/models/color_picker_copy_paste_behavior.dart b/lib/src/models/color_picker_copy_paste_behavior.dart index b4bef4b..10a2c42 100644 --- a/lib/src/models/color_picker_copy_paste_behavior.dart +++ b/lib/src/models/color_picker_copy_paste_behavior.dart @@ -227,7 +227,7 @@ class ColorPickerCopyPasteBehavior with Diagnosticable { /// property values from surrounding `Theme.of(context).iconTheme` if they /// are defined. For any values that remain null value, the following /// fallback defaults are used: - /// ``` + /// ```dart /// color: remains null, so default [IconThemeData] color behavior is kept. /// size: 16 /// opacity: 0.90 @@ -240,7 +240,7 @@ class ColorPickerCopyPasteBehavior with Diagnosticable { /// null or any property in it is null, then it uses property values from /// `Theme.of(context).popupMenuTheme` if they are not null, for any null /// value the following fallback defaults are used: - /// ``` + /// ```dart /// color: theme.cardColor.withOpacity(0.9) /// shape: RoundedRectangleBorder( /// borderRadius: BorderRadius.circular(8), From a66316007a9fd89d41b652c3cb85a5acf084ea65 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 12:29:44 +0200 Subject: [PATCH 07/24] Lint: unnecessary_library_name https://dart.dev/tools/linter-rules/unnecessary_library_name --- lib/flex_color_picker.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/flex_color_picker.dart b/lib/flex_color_picker.dart index c2b1f8b..ffaf6e6 100644 --- a/lib/flex_color_picker.dart +++ b/lib/flex_color_picker.dart @@ -1,6 +1,6 @@ /// A customizable Flutter primary, accent and custom color picker. Includes /// an optional HSV wheel color picker. -library flex_color_picker; +library; export 'src/color_indicator.dart' show ColorIndicator; export 'src/color_picker.dart' show ColorPicker, showColorPickerDialog; From 295610e56ed9ab7b6d990d793d98a1435a51eadb Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 12:42:39 +0200 Subject: [PATCH 08/24] Migrate: Color deprecation withOpacity to withValues --- example/lib/demo/utils/theme.dart | 8 ++-- example/lib/demo/widgets/flex_app_bar.dart | 10 ++--- example/macos/Podfile.lock | 2 +- example/macos/Runner/AppDelegate.swift | 4 ++ lib/src/color_picker.dart | 43 ++++++++++--------- lib/src/widgets/color_code_field.dart | 4 +- lib/src/widgets/context_copy_paste_menu.dart | 2 +- .../widgets/opacity/opacity_slider_track.dart | 2 +- 8 files changed, 40 insertions(+), 35 deletions(-) diff --git a/example/lib/demo/utils/theme.dart b/example/lib/demo/utils/theme.dart index b5e8f1e..36a9910 100644 --- a/example/lib/demo/utils/theme.dart +++ b/example/lib/demo/utils/theme.dart @@ -124,8 +124,8 @@ class AppTheme { color: colorScheme.onSurface, selectedColor: colorScheme.onPrimaryContainer, fillColor: colorScheme.primaryContainer, - hoverColor: colorScheme.primary.withOpacity(0.2), - focusColor: colorScheme.primary.withOpacity(0.3), + hoverColor: colorScheme.primary.withValues(alpha: 0.2), + focusColor: colorScheme.primary.withValues(alpha: 0.3), borderWidth: App.outlineThickness, borderColor: colorScheme.primary, selectedBorderColor: colorScheme.primary, @@ -147,8 +147,8 @@ class AppTheme { ), decoration: BoxDecoration( color: isDark - ? const Color(0xFFCFCFCF).withOpacity(0.94) - : const Color(0xFF444444).withOpacity(0.93), + ? const Color(0xFFCFCFCF).withValues(alpha: 0.94) + : const Color(0xFF444444).withValues(alpha: 0.93), borderRadius: const BorderRadius.all(Radius.circular(6)), border: Border.all( color: isDark ? const Color(0x1FFFFFFF) : const Color(0x1F000000), diff --git a/example/lib/demo/widgets/flex_app_bar.dart b/example/lib/demo/widgets/flex_app_bar.dart index 81a06fc..eb2a0f8 100644 --- a/example/lib/demo/widgets/flex_app_bar.dart +++ b/example/lib/demo/widgets/flex_app_bar.dart @@ -1155,7 +1155,7 @@ class FlexAppBarStyling extends StatelessWidget { effectiveTopPadding - (floatAppBar ? floatPadding.bottom : 0), decoration: BoxDecoration( - color: gradient ? null : color.withOpacity(opacity), + color: gradient ? null : color.withValues(alpha: opacity), borderRadius: effectiveBorderRadius, border: effectiveBorder, gradient: gradient @@ -1164,13 +1164,13 @@ class FlexAppBarStyling extends StatelessWidget { end: AlignmentDirectional.centerEnd, colors: [ if (reverseGradient) - endColor.withOpacity(opacity) + endColor.withValues(alpha: opacity) else - color.withOpacity(startOpacity), + color.withValues(alpha: startOpacity), if (reverseGradient) - color.withOpacity(startOpacity) + color.withValues(alpha: startOpacity) else - endColor.withOpacity(opacity), + endColor.withValues(alpha: opacity), ], ) : null, diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index cec3aba..cc02b49 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -26,4 +26,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/example/macos/Runner/AppDelegate.swift b/example/macos/Runner/AppDelegate.swift index 8e02df2..b3c1761 100644 --- a/example/macos/Runner/AppDelegate.swift +++ b/example/macos/Runner/AppDelegate.swift @@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } } diff --git a/lib/src/color_picker.dart b/lib/src/color_picker.dart index 2c52f06..190091e 100644 --- a/lib/src/color_picker.dart +++ b/lib/src/color_picker.dart @@ -2045,8 +2045,8 @@ class _ColorPickerState extends State { shouldRequestsFocus: _wheelShouldFocus, onChangeStart: (Color color) { widget.onColorChangeStart - ?.call(color.withOpacity(_opacity)); - _addToRecentColors(color.withOpacity(_opacity)); + ?.call(color.withValues(alpha: _opacity)); + _addToRecentColors(color.withValues(alpha: _opacity)); }, onChanged: (Color color) { setState(() { @@ -2061,12 +2061,12 @@ class _ColorPickerState extends State { _wheelShouldFocus = false; _updateActiveSwatch(); }); - widget - .onColorChanged(_selectedColor.withOpacity(_opacity)); + widget.onColorChanged( + _selectedColor.withValues(alpha: _opacity)); }, onChangeEnd: (Color color) { widget.onColorChangeEnd?.call( - color.withOpacity(_opacity), + color.withValues(alpha: _opacity), ); }, onWheel: (bool value) { @@ -2191,9 +2191,9 @@ class _ColorPickerState extends State { _opacity = value; }); widget.onColorChangeStart!( - _selectedColor.withOpacity(_opacity)); + _selectedColor.withValues(alpha: _opacity)); _addToRecentColors( - _selectedColor.withOpacity(_opacity)); + _selectedColor.withValues(alpha: _opacity)); } }, onChanged: (double value) { @@ -2206,7 +2206,7 @@ class _ColorPickerState extends State { _wheelShouldFocus = false; }); widget.onColorChanged( - _selectedColor.withOpacity(_opacity)); + _selectedColor.withValues(alpha: _opacity)); }, onChangeEnd: (double value) { if (widget.onColorChangeEnd != null) { @@ -2215,7 +2215,7 @@ class _ColorPickerState extends State { _opacity = value; }); widget.onColorChangeEnd!( - _selectedColor.withOpacity(_opacity)); + _selectedColor.withValues(alpha: _opacity)); // _addToRecentColors( // _selectedColor.withOpacity(_opacity)); } @@ -2299,7 +2299,7 @@ class _ColorPickerState extends State { if (widget.showColorCode) ColorCodeField( color: widget.enableOpacity - ? _selectedColor.withOpacity(_opacity) + ? _selectedColor.withValues(alpha: _opacity) : _tappedColor, readOnly: _activePicker != ColorPickerType.wheel || widget.colorCodeReadOnly, @@ -2311,8 +2311,8 @@ class _ColorPickerState extends State { enableTooltips: widget.enableTooltips, shouldUpdate: _editShouldUpdate, onColorChanged: (Color color) { - widget.onColorChangeStart - ?.call(_selectedColor.withOpacity(_opacity)); + widget.onColorChangeStart?.call( + _selectedColor.withValues(alpha: _opacity)); setState(() { _tappedColor = color; _selectedColor = color; @@ -2324,11 +2324,11 @@ class _ColorPickerState extends State { _updateActiveSwatch(); }); widget.onColorChanged( - _selectedColor.withOpacity(_opacity)); - widget.onColorChangeEnd - ?.call(_selectedColor.withOpacity(_opacity)); + _selectedColor.withValues(alpha: _opacity)); + widget.onColorChangeEnd?.call( + _selectedColor.withValues(alpha: _opacity)); _addToRecentColors( - _selectedColor.withOpacity(_opacity)); + _selectedColor.withValues(alpha: _opacity)); }, onEditFocused: (bool editInFocus) { _requestEditFocus = false; @@ -2410,8 +2410,9 @@ class _ColorPickerState extends State { } // Call start callback with current selectedColor before change. if (widget.enableOpacity) { - widget.onColorChangeStart?.call(_selectedColor.withOpacity(_opacity)); - _addToRecentColors(_selectedColor.withOpacity(_opacity)); + widget.onColorChangeStart + ?.call(_selectedColor.withValues(alpha: _opacity)); + _addToRecentColors(_selectedColor.withValues(alpha: _opacity)); } else { // This is to allow custom colors with opacity to callback with their // in-built opacity, when opacity is control is not enabled. @@ -2463,8 +2464,8 @@ class _ColorPickerState extends State { }); // Call the change call back with the new color. if (widget.enableOpacity) { - widget.onColorChanged(_selectedColor.withOpacity(_opacity)); - widget.onColorChangeEnd?.call(_selectedColor.withOpacity(_opacity)); + widget.onColorChanged(_selectedColor.withValues(alpha: _opacity)); + widget.onColorChangeEnd?.call(_selectedColor.withValues(alpha: _opacity)); } else { // This is to allow custom colors with opacity to callback with their // in-built opacity, when opacity is control is not enabled. @@ -2521,7 +2522,7 @@ class _ColorPickerState extends State { _selectedColor = clipColor.withAlpha(0xFF); // If opacity is enabled, we capture the opacity from the pasted color. _opacity = widget.enableOpacity ? clipColor.opacity : 1; - _addToRecentColors(_selectedColor.withOpacity(_opacity)); + _addToRecentColors(_selectedColor.withValues(alpha: _opacity)); // Color changed outside wheel and edit field, a new shade or color was // selected outside the wheel and edit, they should update! _wheelShouldUpdate = true; diff --git a/lib/src/widgets/color_code_field.dart b/lib/src/widgets/color_code_field.dart index abd0cdf..2053809 100644 --- a/lib/src/widgets/color_code_field.dart +++ b/lib/src/widgets/color_code_field.dart @@ -351,7 +351,7 @@ class _ColorCodeFieldState extends State { setState(() { color = textColor .toColorShort(widget.copyPasteBehavior.parseShortHexCode) - .withOpacity(color.opacity); + .withValues(alpha: color.a); }); widget.onColorChanged(color); }, @@ -359,7 +359,7 @@ class _ColorCodeFieldState extends State { setState(() { color = textController.text .toColorShort(widget.copyPasteBehavior.parseShortHexCode) - .withOpacity(color.opacity); + .withValues(alpha: color.a); }); textController.text = color.hex; widget.onColorChanged(color); diff --git a/lib/src/widgets/context_copy_paste_menu.dart b/lib/src/widgets/context_copy_paste_menu.dart index 290388f..3bdb29a 100644 --- a/lib/src/widgets/context_copy_paste_menu.dart +++ b/lib/src/widgets/context_copy_paste_menu.dart @@ -151,7 +151,7 @@ class ContextCopyPasteMenu extends StatelessWidget { final PopupMenuThemeData effectiveMenuTheme = theme.popupMenuTheme.copyWith( color: menuThemeData?.color ?? theme.popupMenuTheme.color ?? - theme.cardColor.withOpacity(0.9), + theme.cardColor.withValues(alpha: 0.9), shape: menuThemeData?.shape ?? theme.popupMenuTheme.shape ?? RoundedRectangleBorder( diff --git a/lib/src/widgets/opacity/opacity_slider_track.dart b/lib/src/widgets/opacity/opacity_slider_track.dart index 217f4fb..6f25486 100644 --- a/lib/src/widgets/opacity/opacity_slider_track.dart +++ b/lib/src/widgets/opacity/opacity_slider_track.dart @@ -119,7 +119,7 @@ class OpacitySliderTrack extends SliderTrackShape { ..shader = ui.Gradient.linear( Offset.zero, Offset(trackRect.width, 0), - [color.withOpacity(0), color.withOpacity(1)], + [color.withValues(alpha: 0), color.withValues(alpha: 1)], [0.05, 0.95]); Paint leftTrackPaint; From 9747080a488dbed877d4c79c7ab4612a389b9cb6 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 12:47:32 +0200 Subject: [PATCH 09/24] Migrate: Color deprecation opacity to a --- example/lib/demo/utils/theme.dart | 4 ++-- lib/src/color_picker.dart | 10 +++++----- lib/src/widgets/color_code_field.dart | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/example/lib/demo/utils/theme.dart b/example/lib/demo/utils/theme.dart index 36a9910..a62f839 100644 --- a/example/lib/demo/utils/theme.dart +++ b/example/lib/demo/utils/theme.dart @@ -175,10 +175,10 @@ class AppTheme { final bool isLightBackground = ThemeData.estimateBrightnessForColor(background) == Brightness.light; return isLight - ? (isLightBackground || background.opacity < 0.5) + ? (isLightBackground || background.a < 0.5) ? Colors.black : Colors.white - : (!isLightBackground || background.opacity < 0.5) + : (!isLightBackground || background.a < 0.5) ? Colors.white : Colors.black; } diff --git a/lib/src/color_picker.dart b/lib/src/color_picker.dart index 190091e..ec97b96 100644 --- a/lib/src/color_picker.dart +++ b/lib/src/color_picker.dart @@ -1469,7 +1469,7 @@ class _ColorPickerState extends State { _selectedColor = widget.color.withAlpha(0xFF); _tappedColor = widget.color; // Opacity is captured in _opacity if enabled. - _opacity = widget.enableOpacity ? widget.color.opacity : 1; + _opacity = widget.enableOpacity ? widget.color.a : 1; // Picker labels, use english fallbacks if none provided. _pickerLabels = { ColorPickerType.both: widget.pickerTypeLabels[ColorPickerType.both] ?? @@ -1558,7 +1558,7 @@ class _ColorPickerState extends State { bool shouldFindPickerAndSwatch = false; // Opacity enable/disable changed, update selected color and opacity. if (widget.enableOpacity != oldWidget.enableOpacity) { - _opacity = widget.enableOpacity ? widget.color.opacity : 1; + _opacity = widget.enableOpacity ? widget.color.a : 1; if (_debug) { debugPrint('didUpdateWidget changed: enableOpacity = ' '${widget.enableOpacity == oldWidget.enableOpacity}' @@ -1572,7 +1572,7 @@ class _ColorPickerState extends State { 'color=${widget.color} selectedColor=$_selectedColor'); } _selectedColor = widget.color.withAlpha(0xFF); - _opacity = widget.enableOpacity ? widget.color.opacity : 1; + _opacity = widget.enableOpacity ? widget.color.a : 1; // Make a swatch too be to find it on wheel, if color is there. _typeToSwatchMap[ColorPickerType.wheel] = >[ ColorTools.createPrimarySwatch(_selectedColor), @@ -2406,7 +2406,7 @@ class _ColorPickerState extends State { // uses this flag. If we use Recent colors, we should also extract the // opacity from the selected color, and set it as the current opacity. if (findPicker) { - _opacity = color.opacity; + _opacity = color.a; } // Call start callback with current selectedColor before change. if (widget.enableOpacity) { @@ -2521,7 +2521,7 @@ class _ColorPickerState extends State { // We always remove any alpha from pasted colors. _selectedColor = clipColor.withAlpha(0xFF); // If opacity is enabled, we capture the opacity from the pasted color. - _opacity = widget.enableOpacity ? clipColor.opacity : 1; + _opacity = widget.enableOpacity ? clipColor.a : 1; _addToRecentColors(_selectedColor.withValues(alpha: _opacity)); // Color changed outside wheel and edit field, a new shade or color was // selected outside the wheel and edit, they should update! diff --git a/lib/src/widgets/color_code_field.dart b/lib/src/widgets/color_code_field.dart index 2053809..b8a4d01 100644 --- a/lib/src/widgets/color_code_field.dart +++ b/lib/src/widgets/color_code_field.dart @@ -199,10 +199,10 @@ class _ColorCodeFieldState extends State { ThemeData.estimateBrightnessForColor(unfocusedBackground) == Brightness.light; final Color textColor = isLight - ? (isLightBackground || unfocusedBackground.opacity < 0.5) + ? (isLightBackground || unfocusedBackground.a < 0.5) ? Colors.black : Colors.white - : (!isLightBackground || unfocusedBackground.opacity < 0.5) + : (!isLightBackground || unfocusedBackground.a < 0.5) ? Colors.white : Colors.black; From 73fbe2fa8901e7cd0dd2e279623e022ef0074d38 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 13:34:30 +0200 Subject: [PATCH 10/24] ADD: Color extensions for deprecated 32bit and 8bit colors --- lib/src/color_tools.dart | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/src/color_tools.dart b/lib/src/color_tools.dart index 2d7eb98..50ad399 100644 --- a/lib/src/color_tools.dart +++ b/lib/src/color_tools.dart @@ -784,6 +784,50 @@ class ColorTools { _ColorName.fromColor(color).getName; } +/// Public extensions on [Color]. +extension FlexColorPickerColorExtensions on Color { + /// A 32 bit value representing this color. + /// + /// This feature brings back the Color.value API in a way that is not and + /// will not be deprecated. + /// + /// The bits are assigned as follows: + /// + /// * Bits 24-31 are the alpha value. + /// * Bits 16-23 are the red value. + /// * Bits 8-15 are the green value. + /// * Bits 0-7 are the blue value. + int get value32bit { + return _floatToInt8(a) << 24 | + _floatToInt8(r) << 16 | + _floatToInt8(g) << 8 | + _floatToInt8(b) << 0; + } + + /// The red channel of this color in an 8 bit value. + /// + /// This feature brings back the Color.red API in a way that is not and + /// will not be deprecated. + int get red8bit => (0x00ff0000 & value32bit) >> 16; + + /// The green channel of this color in an 8 bit value. + /// + /// This feature brings back the Color.green API in a way that is not and + /// will not be deprecated. + int get green8bit => (0x0000ff00 & value32bit) >> 8; + + /// The blue channel of this color in an 8 bit value. + /// + /// This feature brings back the Color.blue API in a way that is not and + /// will not be deprecated. + int get blue8bit => (0x000000ff & value32bit) >> 0; + + // Convert float to 8 bit integer. + int _floatToInt8(double x) { + return (x * 255.0).round() & 0xff; + } +} + // Private class for storing and getting the name of a given color. // Use a color or string color code in hex format and get the closest color // name for it, from a list of colors that contains 1566 color names. From c0789c0499ae3923a86f8f577b37d35e902465ba Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 13:35:45 +0200 Subject: [PATCH 11/24] FIX: Deprecated Color.value usage --- example/lib/demo/store/hive_store.dart | 2 +- lib/src/color_picker.dart | 4 +- lib/src/color_picker_extensions.dart | 10 +- lib/src/color_tools.dart | 36 ++-- lib/src/functions/picker_functions.dart | 11 +- lib/src/show_color_picker_dialog.dart | 2 +- lib/src/widgets/recent_colors.dart | 4 +- lib/src/widgets/shade_colors.dart | 4 +- lib/src/widgets/tonal_palette_colors.dart | 2 +- test/color_picker_patrol_test.dart | 247 ++++++++++++---------- test/flex_color_tools_test.dart | 20 +- 11 files changed, 183 insertions(+), 159 deletions(-) diff --git a/example/lib/demo/store/hive_store.dart b/example/lib/demo/store/hive_store.dart index 1a5282a..ae39c22 100644 --- a/example/lib/demo/store/hive_store.dart +++ b/example/lib/demo/store/hive_store.dart @@ -30,7 +30,7 @@ class ColorAdapter extends TypeAdapter { @override void write(BinaryWriter writer, Color obj) { - writer.writeInt(obj.value); + writer.writeInt(obj.value32bit); } @override diff --git a/lib/src/color_picker.dart b/lib/src/color_picker.dart index ec97b96..b721eda 100644 --- a/lib/src/color_picker.dart +++ b/lib/src/color_picker.dart @@ -702,7 +702,7 @@ class ColorPicker extends StatefulWidget { /// Defaults to false. final bool colorCodeReadOnly; - /// Set to true to show the int [Color.value] of the selected [color]. + /// Set to true to show the int [Color] value of the selected [color]. /// /// This is a developer feature, showing the int color value can be /// useful during software development. If enabled the value is shown after @@ -2349,7 +2349,7 @@ class _ColorPickerState extends State { const SizedBox(width: 8), if (widget.showColorValue) SelectableText( - _selectedColor.value.toString(), + _selectedColor.value32bit.toString(), style: effectiveCodeStyle, ), ], diff --git a/lib/src/color_picker_extensions.dart b/lib/src/color_picker_extensions.dart index 8951242..ce9363e 100644 --- a/lib/src/color_picker_extensions.dart +++ b/lib/src/color_picker_extensions.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'color_tools.dart'; + /// Extensions on non nullable [Color] to return it's color value as strings. /// /// The color extension also include getting a color's RGB hex code as a string @@ -10,12 +12,16 @@ import 'package:flutter/material.dart'; extension FlexPickerNoNullColorExtensions on Color { /// Return color's uppercase RGB hex string, including alpha channel. String get hexAlpha { - return value.toRadixString(16).toUpperCase().padLeft(8, '0'); + return value32bit.toRadixString(16).toUpperCase().padLeft(8, '0'); } /// Return color's uppercase RGB hex string, excluding alpha channel. String get hex { - return value.toRadixString(16).toUpperCase().padLeft(8, '0').substring(2); + return value32bit + .toRadixString(16) + .toUpperCase() + .padLeft(8, '0') + .substring(2); } } diff --git a/lib/src/color_tools.dart b/lib/src/color_tools.dart index 50ad399..1ec681c 100644 --- a/lib/src/color_tools.dart +++ b/lib/src/color_tools.dart @@ -193,7 +193,7 @@ class ColorTools { static bool isPrimaryColor(Color color) { for (final ColorSwatch swatch in primaryColors) { for (final int i in _indexPrimaryWith850) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return true; // Color found in a swatch, return true. } } @@ -212,7 +212,7 @@ class ColorTools { // in any swatch/ use case that might be used. This covers normal primary, // primaries with the 850 index, and via primary also accent index. for (final int i in _indexPrimaryWith850) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return true; } } @@ -231,7 +231,7 @@ class ColorTools { static MaterialColor primarySwatch(Color color) { for (final ColorSwatch swatch in primaryColors) { for (final int i in _indexPrimaryWith850) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return swatch as MaterialColor; // Color found in a swatch, return it. } } @@ -303,7 +303,7 @@ class ColorTools { swatch[700] = swatch[700]!.darken(2); swatch[800] = swatch[800]!.darken(3); swatch[900] = swatch[900]!.darken(4); - return MaterialColor(color.value, swatch); + return MaterialColor(color.value32bit, swatch); } /// List of all the standard Material accent color swatches. @@ -410,7 +410,7 @@ class ColorTools { static bool isAccentColor(Color color) { for (final ColorSwatch swatch in accentColors) { for (final int i in _indexAccent) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return true; // Color found in a swatch, return true. } } @@ -431,7 +431,7 @@ class ColorTools { static MaterialAccentColor accentSwatch(Color color) { for (final ColorSwatch swatch in accentColors) { for (final int i in _indexAccent) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return swatch as MaterialAccentColor; // Found in a swatch, return it. } } @@ -468,7 +468,7 @@ class ColorTools { // from the real algorithm. swatch[100] = swatch[100]!.lighten(14); swatch[700] = swatch[700]!.lighten(2); - return MaterialAccentColor(color.value, swatch); + return MaterialAccentColor(color.value32bit, swatch); } /// A list with both primary and accent color Material color swatches. @@ -588,7 +588,7 @@ class ColorTools { static bool isBlackAndWhiteColor(Color color) { for (final ColorSwatch swatch in blackAndWhite) { for (final int i in _indexPrimary) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return true; // Color found in a swatch, return true. } } @@ -608,7 +608,7 @@ class ColorTools { static ColorSwatch blackAndWhiteSwatch(Color color) { for (final ColorSwatch swatch in blackAndWhite) { for (final int i in _indexPrimary) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return swatch; // Color found in a swatch, return it. } } @@ -626,7 +626,7 @@ class ColorTools { if (customSwatch != null) { for (final ColorSwatch swatch in customSwatch.keys) { for (final int i in _indexPrimary) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return true; // Color found in a swatch, return true. } } @@ -649,7 +649,7 @@ class ColorTools { if (customSwatch != null) { for (final ColorSwatch swatch in customSwatch.keys) { for (final int i in _indexPrimary) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { return swatch; // Color found in a swatch so we return it } } @@ -708,7 +708,7 @@ class ColorTools { // If it is a black or white shade, return name, shade and optional index. for (final ColorSwatch swatch in blackAndWhiteNames.keys) { for (final int i in _indexPrimary) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { if (withIndex) { return '${blackAndWhiteNames[swatch]} [$i]'; } else { @@ -720,7 +720,7 @@ class ColorTools { // If it is a primary color, return name, shade and and optional index. for (final ColorSwatch swatch in primaryColorNames.keys) { for (final int i in _indexPrimaryWith850) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { if (withIndex) { return '${primaryColorNames[swatch]} [$i]'; } else { @@ -733,7 +733,7 @@ class ColorTools { // index = [100, 200, 400, 700]; for (final ColorSwatch swatch in accentColorsNames.keys) { for (final int i in _indexAccent) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { if (withIndex) { return '${accentColorsNames[swatch]} [$i]'; } else { @@ -748,7 +748,7 @@ class ColorTools { if (colorSwatchNameMap != null) { for (final ColorSwatch swatch in colorSwatchNameMap.keys) { for (final int i in _indexPrimary) { - if (swatch[i] == color || swatch[i]?.value == color.value) { + if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) { if (withIndex) { return '${colorSwatchNameMap[swatch]} [$i]'; } else { @@ -765,7 +765,7 @@ class ColorTools { /// Return the color value as a HexCode string in uppercase. static String colorCode(Color color) { - return color.value.toRadixString(16).toUpperCase(); + return color.value32bit.toRadixString(16).toUpperCase(); } /// Returns a String name of the color passed to it. @@ -846,7 +846,7 @@ class _ColorName { // Error handling show problematic color codes by returning white color. factory _ColorName.fromColor(Color color) { - final String decodeColor = color.value.toRadixString(16); + final String decodeColor = color.value32bit.toRadixString(16); final int r = color.red; final int g = color.green; final int b = color.blue; @@ -886,7 +886,7 @@ class _ColorName { HSLColor get _hslColor => HSLColor.fromColor(_color); int get getBlue => _color.blue; - String get getCode => _color.value.toRadixString(16); + String get getCode => _color.value32bit.toRadixString(16); int get getGreen => _color.green; int get getHue => _hslColor.hue.toInt(); int get getLightness => (_hslColor.lightness * 100).toInt(); diff --git a/lib/src/functions/picker_functions.dart b/lib/src/functions/picker_functions.dart index 326b868..a622c9a 100644 --- a/lib/src/functions/picker_functions.dart +++ b/lib/src/functions/picker_functions.dart @@ -3,6 +3,7 @@ import 'dart:math' as math; import 'package:flex_seed_scheme/flex_seed_scheme.dart'; import 'package:flutter/material.dart'; +import '../color_tools.dart'; import '../models/color_picker_type.dart'; /// These functions are not library exposed, they are private to the library. @@ -89,7 +90,7 @@ ColorPickerType findColorInSelector({ if (lookInShades) { if (isShadeOfMain(swatch, color, include850)) return key; } else { - if (swatch.value == color.value) return key; + if (swatch.value32bit == color.value32bit) return key; } } } @@ -103,7 +104,7 @@ ColorPickerType findColorInSelector({ return key; } } else { - if (swatch.value == color.withAlpha(0xFF).value) return key; + if (swatch.value32bit == color.withAlpha(0xFF).value32bit) return key; } } } @@ -140,7 +141,9 @@ bool isShadeOfMain( bool include850, ) { for (final Color shade in getMaterialColorShades(mainColor, include850)) { - if (shade == shadeColor || shade.value == shadeColor.value) return true; + if (shade == shadeColor || shade.value32bit == shadeColor.value32bit) { + return true; + } } return false; } @@ -168,7 +171,7 @@ List getMaterialColorShades(ColorSwatch color, bool include850) { /// Return the M3 tonal palette for a passed in color as a list of Colors. List getTonalColors(Color color, bool fixedMinChroma) { - final Cam16 camColor = Cam16.fromInt(color.value); + final Cam16 camColor = Cam16.fromInt(color.value32bit); final FlexTonalPalette tonalColors = FlexTonalPalette.of(camColor.hue, fixedMinChroma ? math.max(48, camColor.chroma) : camColor.chroma); diff --git a/lib/src/show_color_picker_dialog.dart b/lib/src/show_color_picker_dialog.dart index ea27260..82476aa 100644 --- a/lib/src/show_color_picker_dialog.dart +++ b/lib/src/show_color_picker_dialog.dart @@ -445,7 +445,7 @@ Future showColorPickerDialog( /// Defaults to false. bool colorCodeReadOnly = false, - /// Set to true to show the int [Color.value] of the selected `color`. + /// Set to true to show the int [Color] value of the selected `color`. /// /// This is a developer feature, showing the int color value can be /// useful during software development. If enabled the value is shown after diff --git a/lib/src/widgets/recent_colors.dart b/lib/src/widgets/recent_colors.dart index 4302685..698186e 100644 --- a/lib/src/widgets/recent_colors.dart +++ b/lib/src/widgets/recent_colors.dart @@ -85,8 +85,8 @@ class RecentColors extends StatelessWidget { children: [ for (final Color color in recentColors) ColorIndicator( - isSelected: - selectedColor == color || selectedColor.value == color.value, + isSelected: selectedColor == color || + selectedColor.value32bit == color.value32bit, color: color, width: width, height: height, diff --git a/lib/src/widgets/shade_colors.dart b/lib/src/widgets/shade_colors.dart index 3de5510..4762865 100644 --- a/lib/src/widgets/shade_colors.dart +++ b/lib/src/widgets/shade_colors.dart @@ -96,8 +96,8 @@ class ShadeColors extends StatelessWidget { for (final Color color in getMaterialColorShades(activeSwatch, includeIndex850)) ColorIndicator( - isSelected: - selectedColor == color || selectedColor.value == color.value, + isSelected: selectedColor == color || + selectedColor.value32bit == color.value32bit, color: color, width: width, height: height, diff --git a/lib/src/widgets/tonal_palette_colors.dart b/lib/src/widgets/tonal_palette_colors.dart index 4fa800b..f51ad96 100644 --- a/lib/src/widgets/tonal_palette_colors.dart +++ b/lib/src/widgets/tonal_palette_colors.dart @@ -115,7 +115,7 @@ class _TonalPaletteColorsState extends State { for (final Color color in tonalColors) ColorIndicator( isSelected: widget.selectedColor == color || - widget.selectedColor.value == color.value, + widget.selectedColor.value32bit == color.value32bit, color: color, width: widget.width, height: widget.height, diff --git a/test/color_picker_patrol_test.dart b/test/color_picker_patrol_test.dart index 04a3d6f..2bbcdf1 100644 --- a/test/color_picker_patrol_test.dart +++ b/test/color_picker_patrol_test.dart @@ -40,21 +40,21 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - expect(resultColor.value, Colors.red.value); + expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - expect(resultColor.value, Colors.purple.value); + expect(resultColor.value32bit, Colors.purple.value32bit); await $(ColorIndicator).at(20).tap(); - expect(resultColor.value, Colors.purple[100]!.value); + expect(resultColor.value32bit, Colors.purple[100]!.value32bit); // Test accent color picker. expect(find.text('Accent'), findsOneWidget); await $('Accent').tap(); await $(ColorIndicator).tap(); - expect(resultColor.value, Colors.redAccent.value); + expect(resultColor.value32bit, Colors.redAccent.value32bit); await $(ColorIndicator).at(5).tap(); - expect(resultColor.value, Colors.blueAccent.value); + expect(resultColor.value32bit, Colors.blueAccent.value32bit); await $(ColorIndicator).at(18).tap(); - expect(resultColor.value, Colors.blueAccent[400]!.value); + expect(resultColor.value32bit, Colors.blueAccent[400]!.value32bit); }, ); @@ -191,61 +191,65 @@ void main() { expect(find.text('Primary & Accent'), findsOneWidget); await $('Primary & Accent').tap(); await $(ColorIndicator).at(1).tap(); - expect(startColor.value, Colors.red.value); - expect(endColor.value, Colors.redAccent.value); - expect(resultColor.value, Colors.redAccent.value); + expect(startColor.value32bit, Colors.red.value32bit); + expect(endColor.value32bit, Colors.redAccent.value32bit); + expect(resultColor.value32bit, Colors.redAccent.value32bit); // Test recent colors - expect(recentColors.contains(Color(Colors.red.value)), true); + expect(recentColors.contains(Color(Colors.red.value32bit)), true); await $(ColorIndicator).at(34).tap(); - expect(startColor.value, Colors.redAccent.value); - expect(endColor.value, Colors.grey.value); - expect(resultColor.value, Colors.grey.value); + expect(startColor.value32bit, Colors.redAccent.value32bit); + expect(endColor.value32bit, Colors.grey.value32bit); + expect(resultColor.value32bit, Colors.grey.value32bit); // Test recent colors - expect(recentColors.contains(Color(Colors.red.value)), true); - expect(recentColors.contains(Color(Colors.redAccent.value)), true); + expect(recentColors.contains(Color(Colors.red.value32bit)), true); + expect(recentColors.contains(Color(Colors.redAccent.value32bit)), true); await $(ColorIndicator).at(44).tap(); - expect(startColor.value, Colors.grey.value); - expect(endColor.value, Colors.grey[850]!.value); - expect(resultColor.value, Colors.grey[850]!.value); + expect(startColor.value32bit, Colors.grey.value32bit); + expect(endColor.value32bit, Colors.grey[850]!.value32bit); + expect(resultColor.value32bit, Colors.grey[850]!.value32bit); // Test recent colors - expect(recentColors.contains(Color(Colors.red.value)), true); - expect(recentColors.contains(Color(Colors.redAccent.value)), true); - expect(recentColors.contains(Color(Colors.grey.value)), true); + expect(recentColors.contains(Color(Colors.red.value32bit)), true); + expect(recentColors.contains(Color(Colors.redAccent.value32bit)), true); + expect(recentColors.contains(Color(Colors.grey.value32bit)), true); // Test black & white color picker. expect(find.text('Black & White'), findsOneWidget); await $('Black & White').tap(); // Black shade color test await $(ColorIndicator).at(8).tap(); - expect(startColor.value, Colors.grey[850]!.value); - expect(endColor.value, ColorTools.blackShade[600]!.value); - expect(resultColor.value, ColorTools.blackShade[600]!.value); + expect(startColor.value32bit, Colors.grey[850]!.value32bit); + expect(endColor.value32bit, ColorTools.blackShade[600]!.value32bit); + expect(resultColor.value32bit, ColorTools.blackShade[600]!.value32bit); // Test recent colors - expect(recentColors.contains(Color(Colors.red.value)), true); - expect(recentColors.contains(Color(Colors.redAccent.value)), true); - expect(recentColors.contains(Color(Colors.grey.value)), true); - expect(recentColors.contains(Color(Colors.grey[850]!.value)), true); + expect(recentColors.contains(Color(Colors.red.value32bit)), true); + expect(recentColors.contains(Color(Colors.redAccent.value32bit)), true); + expect(recentColors.contains(Color(Colors.grey.value32bit)), true); + expect( + recentColors.contains(Color(Colors.grey[850]!.value32bit)), true); // White shade color test await $(ColorIndicator).at(1).tap(); - expect(resultColor.value, ColorTools.whiteShade[500]!.value); + expect(resultColor.value32bit, ColorTools.whiteShade[500]!.value32bit); // Test recent colors - expect(recentColors.contains(Color(Colors.red.value)), + expect(recentColors.contains(Color(Colors.red.value32bit)), false); // 4 max, no red - expect(recentColors.contains(Color(Colors.redAccent.value)), true); - expect(recentColors.contains(Color(Colors.grey.value)), true); - expect(recentColors.contains(Color(Colors.grey[850]!.value)), true); - expect(recentColors.contains(Color(ColorTools.blackShade[600]!.value)), + expect(recentColors.contains(Color(Colors.redAccent.value32bit)), true); + expect(recentColors.contains(Color(Colors.grey.value32bit)), true); + expect( + recentColors.contains(Color(Colors.grey[850]!.value32bit)), true); + expect( + recentColors + .contains(Color(ColorTools.blackShade[600]!.value32bit)), true); await $(ColorIndicator).at(2).tap(); expect(resultColor, Colors.white); await $(ColorIndicator).at(11).tap(); - expect(resultColor.value, ColorTools.whiteShade[900]!.value); + expect(resultColor.value32bit, ColorTools.whiteShade[900]!.value32bit); // Test Custom color picker. expect(find.text('Custom'), findsOneWidget); await $('Custom').tap(); await $(ColorIndicator).at(1).tap(); - expect(startColor.value, ColorTools.whiteShade[900]!.value); + expect(startColor.value32bit, ColorTools.whiteShade[900]!.value32bit); expect(endColor, const Color(0xFF3700B3)); expect(resultColor, const Color(0xFF3700B3)); @@ -333,7 +337,7 @@ void main() { // Go to another tab select a new color await $('Primary & Accent').tap(); await $(ColorIndicator).at(1).tap(); - expect(resultColor.value, Colors.redAccent.value); + expect(resultColor.value32bit, Colors.redAccent.value32bit); // Copy in the redAccent color await $(ColorPickerToolbar).$(IconButton).at(0).tap( settlePolicy: SettlePolicy.trySettle, @@ -342,7 +346,7 @@ void main() { ); // Select pink color await $(ColorIndicator).at(2).tap(); - expect(resultColor.value, Colors.pink.value); + expect(resultColor.value32bit, Colors.pink.value32bit); // Paste in the red accent value color await $(ColorPickerToolbar).$(IconButton).at(1).tap( settlePolicy: SettlePolicy.trySettle, @@ -350,7 +354,8 @@ void main() { settleTimeout: const Duration(seconds: 2), ); // We pasted the redAccent color, we copied earlier back - expect(Color(resultColor.value), Color(Colors.redAccent.value)); + expect( + Color(resultColor.value32bit), Color(Colors.redAccent.value32bit)); }, ); @@ -426,7 +431,7 @@ void main() { await $('Primary').tap(); // Tap a Material red shade color await $(ColorIndicator).at(22).tap(); - expect(resultColor.value, Colors.red[300]!.value); + expect(resultColor.value32bit, Colors.red[300]!.value32bit); }, ); @@ -563,24 +568,25 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - // expect(resultColor.value, Colors.purple.value); + // expect(resultColor.value32bit, Colors.purple.value32bit); await $(ColorIndicator).at(20).tap(); - // expect(resultColor.value, Colors.purple[100]!.value); + // expect(resultColor.value32bit, Colors.purple[100]!.value32bit); // Test accent color picker. expect(find.text('Accent'), findsOneWidget); await $('Accent').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.redAccent.value); + // expect(resultColor.value32bit, Colors.redAccent.value32bit); await $(ColorIndicator).at(5).tap(); - // expect(resultColor.value, Colors.blueAccent.value); + // expect(resultColor.value32bit, Colors.blueAccent.value32bit); await $(ColorIndicator).at(18).tap(); expect(find.byType(TextButton), findsExactly(2)); await $(TextButton).at(1).tap(); - expect(Color(resultColor.value), Color(Colors.blueAccent[400]!.value)); + expect(Color(resultColor.value32bit), + Color(Colors.blueAccent[400]!.value32bit)); const Color(0xff2979ff); const Color(0xffff9800); @@ -588,21 +594,21 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - // expect(resultColor.value, Colors.purple.value); + // expect(resultColor.value32bit, Colors.purple.value32bit); expect(find.text('OK'), findsOneWidget); await $('OK').tap(); - expect(resultColor.value, Colors.purple.value); + expect(resultColor.value32bit, Colors.purple.value32bit); // Open dialog again await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); expect(find.text('Cancel'), findsOneWidget); await $('Cancel').tap(); - expect(resultColor.value, Colors.purple.value); + expect(resultColor.value32bit, Colors.purple.value32bit); }, ); @@ -669,24 +675,25 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - // expect(resultColor.value, Colors.purple.value); + // expect(resultColor.value32bit, Colors.purple.value32bit); await $(ColorIndicator).at(20).tap(); - // expect(resultColor.value, Colors.purple[100]!.value); + // expect(resultColor.value32bit, Colors.purple[100]!.value32bit); // Test accent color picker. expect(find.text('Accent'), findsOneWidget); await $('Accent').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.redAccent.value); + // expect(resultColor.value32bit, Colors.redAccent.value32bit); await $(ColorIndicator).at(5).tap(); - // expect(resultColor.value, Colors.blueAccent.value); + // expect(resultColor.value32bit, Colors.blueAccent.value32bit); await $(ColorIndicator).at(18).tap(); expect(find.text('OK'), findsOneWidget); await $('OK').tap(); - expect(Color(resultColor.value), Color(Colors.blueAccent[400]!.value)); + expect(Color(resultColor.value32bit), + Color(Colors.blueAccent[400]!.value32bit)); const Color(0xff2979ff); const Color(0xffff9800); @@ -694,21 +701,21 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - // expect(resultColor.value, Colors.purple.value); + // expect(resultColor.value32bit, Colors.purple.value32bit); expect(find.text('OK'), findsOneWidget); await $('OK').tap(); - expect(resultColor.value, Colors.purple.value); + expect(resultColor.value32bit, Colors.purple.value32bit); // Open dialog again await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); expect(find.text('Cancel'), findsOneWidget); await $('Cancel').tap(); - expect(resultColor.value, Colors.purple.value); + expect(resultColor.value32bit, Colors.purple.value32bit); }, ); @@ -784,21 +791,21 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - // expect(resultColor.value, Colors.purple.value); + // expect(resultColor.value32bit, Colors.purple.value32bit); expect(find.text('USE'), findsOneWidget); await $('USE').tap(); - expect(Color(resultColor.value), Color(Colors.purple.value)); + expect(Color(resultColor.value32bit), Color(Colors.purple.value32bit)); // Open dialog again await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); expect(find.text('CLOSE'), findsOneWidget); await $('CLOSE').tap(); - expect(resultColor.value, Colors.purple.value); + expect(resultColor.value32bit, Colors.purple.value32bit); }, ); @@ -876,21 +883,21 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - // expect(resultColor.value, Colors.purple.value); + // expect(resultColor.value32bit, Colors.purple.value32bit); expect(find.text('USE'), findsOneWidget); await $('USE').tap(); - expect(Color(resultColor.value), Color(Colors.purple.value)); + expect(Color(resultColor.value32bit), Color(Colors.purple.value32bit)); // Open dialog again await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); expect(find.text('CLOSE'), findsOneWidget); await $('CLOSE').tap(); - expect(resultColor.value, Colors.purple.value); + expect(resultColor.value32bit, Colors.purple.value32bit); }, ); @@ -966,12 +973,12 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - // expect(resultColor.value, Colors.purple.value); + // expect(resultColor.value32bit, Colors.purple.value32bit); expect(find.text('USE'), findsOneWidget); await $('USE').tap(); - expect(Color(resultColor.value), Color(Colors.purple.value)); + expect(Color(resultColor.value32bit), Color(Colors.purple.value32bit)); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -985,14 +992,14 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); // Find the ToolBar expect(find.byType(ColorPickerToolbar), findsOneWidget); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 4th button is OK, since close is NOT last await $(ColorPickerToolbar).$(IconButton).at(3).tap(); - expect(resultColor.value, Colors.red.value); + expect(resultColor.value32bit, Colors.red.value32bit); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1000,7 +1007,7 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).at(3).tap(); - // expect(resultColor.value, Colors.deepPurple.value); + // expect(resultColor.value32bit, Colors.deepPurple.value32bit); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 3rd button is Close, since close is NOT last @@ -1008,7 +1015,7 @@ void main() { // Dialog is closed expect(find.text('Open'), findsOneWidget); // Expect no change in color - expect(resultColor.value, Colors.red.value); + expect(resultColor.value32bit, Colors.red.value32bit); }, ); @@ -1086,12 +1093,12 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(2).tap(); - // expect(resultColor.value, Colors.purple.value); + // expect(resultColor.value32bit, Colors.purple.value32bit); expect(find.text('USE'), findsOneWidget); await $('USE').tap(); - expect(Color(resultColor.value), Color(Colors.purple.value)); + expect(Color(resultColor.value32bit), Color(Colors.purple.value32bit)); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1105,14 +1112,14 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); // Find the ToolBar expect(find.byType(ColorPickerToolbar), findsOneWidget); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 4th button is OK, since close is NOT last await $(ColorPickerToolbar).$(IconButton).at(3).tap(); - expect(resultColor.value, Colors.red.value); + expect(resultColor.value32bit, Colors.red.value32bit); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1120,7 +1127,7 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).at(3).tap(); - // expect(resultColor.value, Colors.deepPurple.value); + // expect(resultColor.value32bit, Colors.deepPurple.value32bit); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 3rd button is Close, since close is NOT last @@ -1128,7 +1135,7 @@ void main() { // Dialog is closed expect(find.text('Open'), findsOneWidget); // Expect no change in color - expect(resultColor.value, Colors.red.value); + expect(resultColor.value32bit, Colors.red.value32bit); }, ); @@ -1207,12 +1214,13 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(6).tap(); - // expect(resultColor.value, Colors.lightBlue.value); + // expect(resultColor.value32bit, Colors.lightBlue.value32bit); expect(find.text('Do'), findsOneWidget); await $('Do').tap(); - expect(Color(resultColor.value), Color(Colors.lightBlue.value)); + expect( + Color(resultColor.value32bit), Color(Colors.lightBlue.value32bit)); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1226,14 +1234,14 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); // Find the ToolBar expect(find.byType(ColorPickerToolbar), findsOneWidget); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 4th button is Close, since close is last await $(ColorPickerToolbar).$(IconButton).at(3).tap(); - expect(resultColor.value, Colors.lightBlue.value); + expect(resultColor.value32bit, Colors.lightBlue.value32bit); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1241,7 +1249,7 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).at(3).tap(); - // expect(resultColor.value, Colors.deepPurple.value); + // expect(resultColor.value32bit, Colors.deepPurple.value32bit); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 3rd button is OK, since close is NOT last @@ -1249,7 +1257,8 @@ void main() { // Dialog is closed expect(find.text('Open'), findsOneWidget); // Expect no change in color - expect(Color(resultColor.value), Color(Colors.deepPurple.value)); + expect( + Color(resultColor.value32bit), Color(Colors.deepPurple.value32bit)); // Color(0xff673ab7); }, ); @@ -1329,12 +1338,13 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(6).tap(); - // expect(resultColor.value, Colors.lightBlue.value); + // expect(resultColor.value32bit, Colors.lightBlue.value32bit); expect(find.text('Do'), findsOneWidget); await $('Do').tap(); - expect(Color(resultColor.value), Color(Colors.lightBlue.value)); + expect( + Color(resultColor.value32bit), Color(Colors.lightBlue.value32bit)); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1348,14 +1358,14 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); // Find the ToolBar expect(find.byType(ColorPickerToolbar), findsOneWidget); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 4th button is Close, since close is last await $(ColorPickerToolbar).$(IconButton).at(3).tap(); - expect(resultColor.value, Colors.lightBlue.value); + expect(resultColor.value32bit, Colors.lightBlue.value32bit); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1363,7 +1373,7 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).at(3).tap(); - // expect(resultColor.value, Colors.deepPurple.value); + // expect(resultColor.value32bit, Colors.deepPurple.value32bit); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 3rd button is OK, since close is NOT last @@ -1371,7 +1381,8 @@ void main() { // Dialog is closed expect(find.text('Open'), findsOneWidget); // Expect no change in color - expect(Color(resultColor.value), Color(Colors.deepPurple.value)); + expect( + Color(resultColor.value32bit), Color(Colors.deepPurple.value32bit)); // Color(0xff673ab7); }, ); @@ -1465,25 +1476,26 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(6).tap(); - // expect(resultColor.value, Colors.lightBlue.value); + // expect(resultColor.value32bit, Colors.lightBlue.value32bit); expect(find.text('OK'), findsOneWidget); await $('OK').tap(); - expect(Color(resultColor.value), Color(Colors.lightBlue.value)); + expect( + Color(resultColor.value32bit), Color(Colors.lightBlue.value32bit)); // Open dialog again await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); // Find the ToolBar expect(find.byType(ColorPickerToolbar), findsOneWidget); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 4th button is Close, since close is last await $(ColorPickerToolbar).$(IconButton).at(3).tap(); - expect(resultColor.value, Colors.lightBlue.value); + expect(resultColor.value32bit, Colors.lightBlue.value32bit); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1497,7 +1509,7 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).at(3).tap(); - // expect(resultColor.value, Colors.deepPurple.value); + // expect(resultColor.value32bit, Colors.deepPurple.value32bit); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 3rd button is OK, since close is NOT last @@ -1505,7 +1517,8 @@ void main() { // Dialog is closed expect(find.text('Open'), findsOneWidget); // Expect no change in color - expect(Color(resultColor.value), Color(Colors.deepPurple.value)); + expect( + Color(resultColor.value32bit), Color(Colors.deepPurple.value32bit)); // Open dialog again await $('Open').tap(); @@ -1519,7 +1532,7 @@ void main() { expect(find.text('OK'), findsOneWidget); await $('OK').tap(); // We get a purple color from smack in the middle - expect(Color(resultColor.value), const Color(0xff574080)); + expect(Color(resultColor.value32bit), const Color(0xff574080)); }, ); @@ -1614,25 +1627,26 @@ void main() { expect(find.text('Primary'), findsOneWidget); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); await $(ColorIndicator).at(6).tap(); - // expect(resultColor.value, Colors.lightBlue.value); + // expect(resultColor.value32bit, Colors.lightBlue.value32bit); expect(find.text('OK'), findsOneWidget); await $('OK').tap(); - expect(Color(resultColor.value), Color(Colors.lightBlue.value)); + expect( + Color(resultColor.value32bit), Color(Colors.lightBlue.value32bit)); // Open dialog again await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).tap(); - // expect(resultColor.value, Colors.red.value); + // expect(resultColor.value32bit, Colors.red.value32bit); // Find the ToolBar expect(find.byType(ColorPickerToolbar), findsOneWidget); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 4th button is Close, since close is last await $(ColorPickerToolbar).$(IconButton).at(3).tap(); - expect(resultColor.value, Colors.lightBlue.value); + expect(resultColor.value32bit, Colors.lightBlue.value32bit); // Dialog is closed expect(find.text('Open'), findsOneWidget); @@ -1646,7 +1660,7 @@ void main() { await $('Open').tap(); await $('Primary').tap(); await $(ColorIndicator).at(3).tap(); - // expect(resultColor.value, Colors.deepPurple.value); + // expect(resultColor.value32bit, Colors.deepPurple.value32bit); // Find the ToolBar buttons, 4 of them configured. expect($(ColorPickerToolbar).$(IconButton), findsNWidgets(4)); // Close via toolbar, 3rd button is OK, since close is NOT last @@ -1654,7 +1668,8 @@ void main() { // Dialog is closed expect(find.text('Open'), findsOneWidget); // Expect no change in color - expect(Color(resultColor.value), Color(Colors.deepPurple.value)); + expect( + Color(resultColor.value32bit), Color(Colors.deepPurple.value32bit)); // Open dialog again await $('Open').tap(); @@ -1668,7 +1683,7 @@ void main() { expect(find.text('OK'), findsOneWidget); await $('OK').tap(); // We get a purple color from smack in the middle - expect(Color(resultColor.value), const Color(0xff574080)); + expect(Color(resultColor.value32bit), const Color(0xff574080)); }, ); diff --git a/test/flex_color_tools_test.dart b/test/flex_color_tools_test.dart index fae1256..90aa1f9 100644 --- a/test/flex_color_tools_test.dart +++ b/test/flex_color_tools_test.dart @@ -208,7 +208,7 @@ void main() { expect( ColorTools.materialNameAndCode(swatch[i]!), '${ColorTools.primaryColorNames[swatch]} [$i] ' - '(0x${swatch[i]!.value.toRadixString(16).toUpperCase()})'); + '(0x${swatch[i]!.value32bit.toRadixString(16).toUpperCase()})'); }); test( 'ColorTools.materialNameAndARGBCode ' @@ -218,7 +218,7 @@ void main() { expect( ColorTools.materialNameAndARGBCode(swatch[i]!), '${ColorTools.primaryColorNames[swatch]} [$i] ' - '(${swatch[i]!.value.toRadixString(16).toUpperCase()})'); + '(${swatch[i]!.value32bit.toRadixString(16).toUpperCase()})'); }); } } @@ -360,7 +360,7 @@ void main() { final MaterialColor refColor = ColorTools.createPrimarySwatch(const Color(0xFF132B80)); test('Test swatch value is provided Color value 0xFF132B80', () { - expect(refColor.value, 0xFF132B80); + expect(refColor.value32bit, 0xFF132B80); }); test('Test swatch index [50] reference value 0xffb9c0d9', () { expect(refColor[50], const Color(0xffb9c0d9)); @@ -563,7 +563,7 @@ void main() { expect( ColorTools.materialNameAndCode(swatch[i]!), '${ColorTools.accentColorsNames[swatch]} [$i] ' - '(0x${swatch[i]!.value.toRadixString(16).toUpperCase()})'); + '(0x${swatch[i]!.value32bit.toRadixString(16).toUpperCase()})'); }); test( 'ColorTools.materialNameAndARGBCode ' @@ -573,7 +573,7 @@ void main() { expect( ColorTools.materialNameAndARGBCode(swatch[i]!), '${ColorTools.accentColorsNames[swatch]} [$i] ' - '(${swatch[i]!.value.toRadixString(16).toUpperCase()})'); + '(${swatch[i]!.value32bit.toRadixString(16).toUpperCase()})'); }); } } @@ -630,7 +630,7 @@ void main() { final MaterialAccentColor refColor = ColorTools.createAccentSwatch(const Color(0xFF03DAC6)); test('Test swatch value is provided Color value 0xFF03DAC6', () { - expect(refColor.value, 0xFF03DAC6); + expect(refColor.value32bit, 0xFF03DAC6); }); test('Test swatch index [100] reference value 0xff58eadc', () { expect(refColor[100], const Color(0xff58eadc)); @@ -791,7 +791,7 @@ void main() { expect( ColorTools.materialNameAndCode(swatch[i]!), '${ColorTools.blackAndWhiteNames[swatch]} [$i] ' - '(0x${swatch[i]!.value.toRadixString(16).toUpperCase()})'); + '(0x${swatch[i]!.value32bit.toRadixString(16).toUpperCase()})'); }); test( 'ColorTools.materialNameAndARGBCode ' @@ -801,7 +801,7 @@ void main() { expect( ColorTools.materialNameAndARGBCode(swatch[i]!), '${ColorTools.blackAndWhiteNames[swatch]} [$i] ' - '(${swatch[i]!.value.toRadixString(16).toUpperCase()})'); + '(${swatch[i]!.value32bit.toRadixString(16).toUpperCase()})'); }); } } @@ -1030,7 +1030,7 @@ void main() { ColorTools.materialNameAndCode(swatch[i]!, colorSwatchNameMap: refCustomColors), '${refCustomColors[swatch]} [$i] ' - '(0x${swatch[i]!.value.toRadixString(16).toUpperCase()})'); + '(0x${swatch[i]!.value32bit.toRadixString(16).toUpperCase()})'); }); test( 'ColorTools.materialNameAndARGBCode ' @@ -1043,7 +1043,7 @@ void main() { ColorTools.materialNameAndARGBCode(swatch[i]!, colorSwatchNameMap: refCustomColors), '${refCustomColors[swatch]} [$i] ' - '(${swatch[i]!.value.toRadixString(16).toUpperCase()})'); + '(${swatch[i]!.value32bit.toRadixString(16).toUpperCase()})'); }); } } From 7cee9993ebe90ee291991e1890d04fb670b30436 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 13:41:40 +0200 Subject: [PATCH 12/24] FIX: Deprecated Color.red .green .blue usage --- lib/src/color_tools.dart | 24 ++++++++++++------------ test/flex_color_tools_test.dart | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/src/color_tools.dart b/lib/src/color_tools.dart index 1ec681c..35decae 100644 --- a/lib/src/color_tools.dart +++ b/lib/src/color_tools.dart @@ -281,9 +281,9 @@ class ColorTools { static MaterialColor createPrimarySwatch(Color color) { final Map swatch = {}; final int a = color.alpha; - final int r = color.red; - final int g = color.green; - final int b = color.blue; + final int r = color.red8bit; + final int g = color.green8bit; + final int b = color.blue8bit; for (final int strength in _indexPrimary) { final double ds = 0.5 - strength / 1000; swatch[strength] = Color.fromARGB( @@ -453,9 +453,9 @@ class ColorTools { static MaterialAccentColor createAccentSwatch(Color color) { final Map swatch = {}; final int a = color.alpha; - final int r = color.red; - final int g = color.green; - final int b = color.blue; + final int r = color.red8bit; + final int g = color.green8bit; + final int b = color.blue8bit; for (final int strength in _indexAccent) { final double ds = 0.2 - strength / 1000; swatch[strength] = Color.fromARGB( @@ -847,9 +847,9 @@ class _ColorName { // Error handling show problematic color codes by returning white color. factory _ColorName.fromColor(Color color) { final String decodeColor = color.value32bit.toRadixString(16); - final int r = color.red; - final int g = color.green; - final int b = color.blue; + final int r = color.red8bit; + final int g = color.green8bit; + final int b = color.blue8bit; final HSLColor hsl = HSLColor.fromColor(color); final int h = hsl.hue.toInt(); @@ -885,13 +885,13 @@ class _ColorName { final String _name; HSLColor get _hslColor => HSLColor.fromColor(_color); - int get getBlue => _color.blue; + int get getBlue => _color.blue8bit; String get getCode => _color.value32bit.toRadixString(16); - int get getGreen => _color.green; + int get getGreen => _color.green8bit; int get getHue => _hslColor.hue.toInt(); int get getLightness => (_hslColor.lightness * 100).toInt(); String get getName => _name; - int get getRed => _color.red; + int get getRed => _color.red8bit; int get getSaturation => (_hslColor.saturation * 100).toInt(); // A const list of 1566 named colors diff --git a/test/flex_color_tools_test.dart b/test/flex_color_tools_test.dart index 90aa1f9..0b18dce 100644 --- a/test/flex_color_tools_test.dart +++ b/test/flex_color_tools_test.dart @@ -1101,11 +1101,11 @@ void main() { // A custom color code modifier that changes the RGB value up a bit, but not // enough to result in a different color Color colorPlusOneRGB(Color color) { - int red = color.red; + int red = color.red8bit; if (red > 0x10 && red < 0xEF) red++; - int green = color.green; + int green = color.green8bit; if (green > 0x10 && green < 0xEF) green++; - int blue = color.blue; + int blue = color.blue8bit; if (blue > 0x11 && blue < 0xEE) blue++; return Color.fromARGB(0xFF, red, green, blue); } From 4036c466082c9e7e3e97b111aba006416f14947e Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 13:43:36 +0200 Subject: [PATCH 13/24] ADD: Color extension for deprecated Color.alpha --- lib/src/color_tools.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/color_tools.dart b/lib/src/color_tools.dart index 35decae..1e05078 100644 --- a/lib/src/color_tools.dart +++ b/lib/src/color_tools.dart @@ -804,6 +804,15 @@ extension FlexColorPickerColorExtensions on Color { _floatToInt8(b) << 0; } + /// The alpha channel of this color in an 8 bit value. + /// + /// A value of 0 means this color is fully transparent. A value of 255 means + /// this color is fully opaque. + /// + /// This feature brings back the Color.alpha API in a way that is not and + /// will not be deprecated. + int get alpha8bit => (0xff000000 & value32bit) >> 24; + /// The red channel of this color in an 8 bit value. /// /// This feature brings back the Color.red API in a way that is not and From d5effc8cf47e41fdac85401c031b6177e2d27e34 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 13:44:50 +0200 Subject: [PATCH 14/24] FIX: Deprecated Color.alpha usage --- lib/src/color_tools.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/color_tools.dart b/lib/src/color_tools.dart index 1e05078..27f2330 100644 --- a/lib/src/color_tools.dart +++ b/lib/src/color_tools.dart @@ -280,7 +280,7 @@ class ColorTools { /// https://material.io/resources/color/#!/?view.left=0&view.right=0&primary.color=6002ee static MaterialColor createPrimarySwatch(Color color) { final Map swatch = {}; - final int a = color.alpha; + final int a = color.alpha8bit; final int r = color.red8bit; final int g = color.green8bit; final int b = color.blue8bit; @@ -452,7 +452,7 @@ class ColorTools { /// for higher indexes. static MaterialAccentColor createAccentSwatch(Color color) { final Map swatch = {}; - final int a = color.alpha; + final int a = color.alpha8bit; final int r = color.red8bit; final int g = color.green8bit; final int b = color.blue8bit; From 46b0f73e7110a82edfe39c69e5ceb42181a759ae Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 13:51:30 +0200 Subject: [PATCH 15/24] UPDATE: Tests with new string outputs due to Color class changes. --- test/color_picker_action_buttons_test.dart | 2 +- test/color_picker_copy_paste_behavior_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/color_picker_action_buttons_test.dart b/test/color_picker_action_buttons_test.dart index 81aed30..c78c4bf 100644 --- a/test/color_picker_action_buttons_test.dart +++ b/test/color_picker_action_buttons_test.dart @@ -92,7 +92,7 @@ void main() { 'EXPECT exact print string value.', () { expect(m4.toString(), equalsIgnoringHashCodes( // ignore: lines_longer_than_80_chars - 'ColorPickerActionButtons#00000(okButton: true, closeButton: true, okIcon: IconData(U+0E085), closeIcon: IconData(U+0E139), closeIsLast: false, okTooltip: "GO", closeTooltip: "OFF", closeTooltipIsClose: false, toolIconsThemeData: IconThemeData#00000(size: 30.0, color: Color(0xff000000), opacity: 1.0), visualDensity: VisualDensity#00000(h: -1.0, v: -1.0)(horizontal: -1.0, vertical: -1.0), alignment: Alignment.topLeft, splashRadius: 30.0, constraints: BoxConstraints(46.0<=w<=Infinity, 46.0<=h<=Infinity), dialogActionButtons: false, dialogActionOnlyOkButton: true, dialogActionOrder: adaptive, dialogActionIcons: true, dialogCancelButtonLabel: "DONE", dialogCancelButtonType: outlined, dialogOkButtonLabel: "OKAY", dialogOkButtonType: elevated, useRootNavigator: false)')); + 'ColorPickerActionButtons#7bd82(okButton: true, closeButton: true, okIcon: IconData(U+0E085), closeIcon: IconData(U+0E139), closeIsLast: false, okTooltip: "GO", closeTooltip: "OFF", closeTooltipIsClose: false, toolIconsThemeData: IconThemeData#f1304(size: 30.0, color: Color(alpha: 1.0000, red: 0.0000, green: 0.0000, blue: 0.0000, colorSpace: ColorSpace.sRGB), opacity: 1.0), visualDensity: VisualDensity#b6c96(h: -1.0, v: -1.0)(horizontal: -1.0, vertical: -1.0), alignment: Alignment.topLeft, splashRadius: 30.0, constraints: BoxConstraints(46.0<=w<=Infinity, 46.0<=h<=Infinity), dialogActionButtons: false, dialogActionOnlyOkButton: true, dialogActionOrder: adaptive, dialogActionIcons: true, dialogCancelButtonLabel: "DONE", dialogCancelButtonType: outlined, dialogOkButtonLabel: "OKAY", dialogOkButtonType: elevated, useRootNavigator: false)')); }); test( 'CPAB2.2: Test toStringShort implemented via debugFillProperties ' diff --git a/test/color_picker_copy_paste_behavior_test.dart b/test/color_picker_copy_paste_behavior_test.dart index 89d917c..6174d05 100644 --- a/test/color_picker_copy_paste_behavior_test.dart +++ b/test/color_picker_copy_paste_behavior_test.dart @@ -135,7 +135,7 @@ void main() { 'EXPECT exact print string value.', () { expect(m4.toString(), equalsIgnoringHashCodes( // ignore: lines_longer_than_80_chars - 'ColorPickerCopyPasteBehavior#00000(ctrlC: false, ctrlV: false, autoFocus: true, copyButton: true, pasteButton: true, copyIcon: IconData(U+0E085), pasteIcon: IconData(U+0E16A), copyTooltip: "COPY", pasteTooltip: "PASTE", copyFormat: numHexAARRGGBB, longPressMenu: true, secondaryMenu: true, secondaryOnDesktopLongOnDevice: true, secondaryOnDesktopLongOnDeviceAndWeb: true, editFieldCopyButton: false, menuIconThemeData: IconThemeData#00000(size: 30.0, color: Color(0xff000000), opacity: 1.0), menuThemeData: PopupMenuThemeData#00000(color: Color(0xffffffff), shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero), elevation: 3.0, text style: TextStyle(inherit: true, size: 12.0), enableFeedback: true), menuWidth: 85.0, menuItemHeight: 35.0, snackBarParseError: true, snackBarMessage: "Something went wrong", snackBarDuration: 0:00:01.500000, feedbackParseError: true, parseShortHexCode: true, editUsesParsedPaste: true)')); + 'ColorPickerCopyPasteBehavior#1d1a2(ctrlC: false, ctrlV: false, autoFocus: true, copyButton: true, pasteButton: true, copyIcon: IconData(U+0E085), pasteIcon: IconData(U+0E16A), copyTooltip: "COPY", pasteTooltip: "PASTE", copyFormat: numHexAARRGGBB, longPressMenu: true, secondaryMenu: true, secondaryOnDesktopLongOnDevice: true, secondaryOnDesktopLongOnDeviceAndWeb: true, editFieldCopyButton: false, menuIconThemeData: IconThemeData#6d8b7(size: 30.0, color: Color(alpha: 1.0000, red: 0.0000, green: 0.0000, blue: 0.0000, colorSpace: ColorSpace.sRGB), opacity: 1.0), menuThemeData: PopupMenuThemeData#30106(color: Color(alpha: 1.0000, red: 1.0000, green: 1.0000, blue: 1.0000, colorSpace: ColorSpace.sRGB), shape: RoundedRectangleBorder(BorderSide(width: 0.0, style: none), BorderRadius.zero), elevation: 3.0, text style: TextStyle(inherit: true, size: 12.0), enableFeedback: true), menuWidth: 85.0, menuItemHeight: 35.0, snackBarParseError: true, snackBarMessage: "Something went wrong", snackBarDuration: 0:00:01.500000, feedbackParseError: true, parseShortHexCode: true, editUsesParsedPaste: true)')); }); test( 'CPCPB2.2: Test toStringShort implemented via debugFillProperties ' From f69350fc2f51bc6ebb165d71880216216dcc57b8 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 17:27:40 +0200 Subject: [PATCH 16/24] FIX: Comment spelling --- lib/src/widgets/opacity/opacity_slider.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/widgets/opacity/opacity_slider.dart b/lib/src/widgets/opacity/opacity_slider.dart index cd2b89c..d1f84a8 100644 --- a/lib/src/widgets/opacity/opacity_slider.dart +++ b/lib/src/widgets/opacity/opacity_slider.dart @@ -22,7 +22,7 @@ import 'opacity_slider_track.dart'; /// The slider has 255 steps so that it is possible to select any corresponding /// 8-bit alpha channel value. If the opacity is applied to a color using /// `withOpacity` and the alpha value displayed in the resulting color, this -/// be observed. +/// can be observed. /// /// The opacity value is returned via the onChanged called back. There are /// also callbacks for [onChangeStart] and [onChangeEnd]. From 3914f61cfcc7ad0360af6e3a85a4e7963555cec7 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 17:28:12 +0200 Subject: [PATCH 17/24] FIX: Force Opacity slider to think it is not rounded --- lib/src/widgets/opacity/opacity_slider_track.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/widgets/opacity/opacity_slider_track.dart b/lib/src/widgets/opacity/opacity_slider_track.dart index 6f25486..91cdb18 100644 --- a/lib/src/widgets/opacity/opacity_slider_track.dart +++ b/lib/src/widgets/opacity/opacity_slider_track.dart @@ -37,6 +37,15 @@ class OpacitySliderTrack extends SliderTrackShape { /// Paint used to draw the background image on the slider track. final Paint bgImagePaint; + // This override is need to allow the thumb to be drawn all the way to the e + // edge of the rounded track. We can kind of have to lie to it to say it is + // not rounded, even if it is, so that the thumb can be drawn all the way to + // the edge. This became necessary when in Flutter version 3.27.0. + // Unfortunately it does not, respect this when Slider is discrete. + // A fix is in progress in Flutter to support this. + @override + bool get isRounded => false; + /// Returns a rect that represents the track bounds that fits within the /// [Slider]. /// From f668c98b8e457d8478780da7c66c1d998e179820 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 17:39:54 +0200 Subject: [PATCH 18/24] Update: Version info --- example/lib/demo/screens/color_picker/about.dart | 2 +- example/lib/demo/utils/app.dart | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/example/lib/demo/screens/color_picker/about.dart b/example/lib/demo/screens/color_picker/about.dart index a3b9d55..9edd733 100644 --- a/example/lib/demo/screens/color_picker/about.dart +++ b/example/lib/demo/screens/color_picker/about.dart @@ -67,7 +67,7 @@ void showAppAboutDialog(BuildContext context) { ), TextSpan( style: footerStyle, - text: 'Live Web demo built with ${App.flutterVersion}, ' + text: 'Built with Flutter ${App.flutterVersion}, ' 'using ${App.packageVersion}\n\n', ), ], diff --git a/example/lib/demo/utils/app.dart b/example/lib/demo/utils/app.dart index 509a2a1..462a987 100644 --- a/example/lib/demo/utils/app.dart +++ b/example/lib/demo/utils/app.dart @@ -1,4 +1,5 @@ import 'package:flex_color_picker/flex_color_picker.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; /// Contains used constants for doubles, strings and colors. @@ -9,14 +10,24 @@ class App { // Web demo with inside the app. Shown on the start screen in the demo, // so people testing it don't have to ask. Also info for the About screen. static const String appName = 'FlexColorPicker'; - static const String version = '3.7.0-beta'; + static const String version = '3.7.0'; static const String packageVersion = 'FlexColorPicker package $version'; static final Uri packageUri = Uri( scheme: 'https', host: 'pub.dev', path: 'packages/flex_color_picker', ); - static const String flutterVersion = 'Channel stable 3.27.0 (canvaskit)'; + + // Check if this is a Web-WASM build, Web-JS build or native VM build. + static const bool isRunningWithWasm = + bool.fromEnvironment('dart.tool.dart2wasm'); + static const String buildType = isRunningWithWasm + ? ', WasmGC' + : kIsWeb + ? ', JS' + : ', native VM'; + + static const String flutterVersion = 'stable 3.27.0 (canvaskit$buildType)'; static const String copyright = '© 2020 - 2024'; static const String author = 'Mike Rydstrom'; static const String license = 'BSD 3-Clause License'; From fc7a3f9b526f62c2ee7c2f8b72db85197c9d2dc5 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 17:41:47 +0200 Subject: [PATCH 19/24] Update CHANGELOG.md --- CHANGELOG.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f0f73a..065100a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,15 @@ All notable changes to the **FlexColorPicker** package are documented in this file. -## 3.7.0 WIP/DRAFT +## 3.7.0 -**Dec 12, 2024** +**Dec 13, 2024** **PACKAGE** -* First prep for Flutter 3.27.0 update with new Color features that supports wide gamut. In total, 243 deprecations will have to be replaced with the new Color features. +* Updated the package to support and require min Flutter v3.27.0. +* Fixed all new analyzer lint warnings and removed usage of all deprecated `Color` properties. + * While the package now uses the updated `Color` class with support for wide gamut, the color inputs and outputs are still 32-bit RGB color values. A future update may add support for more and new color formats. ## 3.6.0 From 9b565a0785e1c309105adeb7b0e2b86d6bffc3ea Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 20:21:46 +0200 Subject: [PATCH 20/24] Remove: isRounded override, does not and will not help --- lib/src/widgets/opacity/opacity_slider_track.dart | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/src/widgets/opacity/opacity_slider_track.dart b/lib/src/widgets/opacity/opacity_slider_track.dart index 91cdb18..6f25486 100644 --- a/lib/src/widgets/opacity/opacity_slider_track.dart +++ b/lib/src/widgets/opacity/opacity_slider_track.dart @@ -37,15 +37,6 @@ class OpacitySliderTrack extends SliderTrackShape { /// Paint used to draw the background image on the slider track. final Paint bgImagePaint; - // This override is need to allow the thumb to be drawn all the way to the e - // edge of the rounded track. We can kind of have to lie to it to say it is - // not rounded, even if it is, so that the thumb can be drawn all the way to - // the edge. This became necessary when in Flutter version 3.27.0. - // Unfortunately it does not, respect this when Slider is discrete. - // A fix is in progress in Flutter to support this. - @override - bool get isRounded => false; - /// Returns a rect that represents the track bounds that fits within the /// [Slider]. /// From ea86870aac4ef71e98801a87dba89b095fa66fd6 Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 20:32:53 +0200 Subject: [PATCH 21/24] Web demo app: Fix minor layout issues --- .../color_picker/color_picker_screen.dart | 1 + .../copy_format_switch.dart | 5 +- .../pickers_enabled_switch.dart | 70 +++++++++---------- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/example/lib/demo/screens/color_picker/color_picker_screen.dart b/example/lib/demo/screens/color_picker/color_picker_screen.dart index e64a33d..7f0d0d6 100644 --- a/example/lib/demo/screens/color_picker/color_picker_screen.dart +++ b/example/lib/demo/screens/color_picker/color_picker_screen.dart @@ -195,6 +195,7 @@ class _Column1 extends StatelessWidget { 'during change and when change ended.'), ), const Divider(), + const ListTile(title: Text('Copy format')), const CopyFormatSwitch(), const SizedBox(height: 8), const ListTile( diff --git a/example/lib/demo/screens/color_picker/picker_toggle_buttons/copy_format_switch.dart b/example/lib/demo/screens/color_picker/picker_toggle_buttons/copy_format_switch.dart index d23bb9a..7bc46fa 100644 --- a/example/lib/demo/screens/color_picker/picker_toggle_buttons/copy_format_switch.dart +++ b/example/lib/demo/screens/color_picker/picker_toggle_buttons/copy_format_switch.dart @@ -23,9 +23,8 @@ class CopyFormatSwitch extends ConsumerWidget { tooltip: 'ColorPicker(copyPasteBehavior:\n' ' ColorPickerCopyPasteBehavior(copyFormat:\n' ' $copyFormat))', - child: ListTile( - title: const Text('Copy format'), - trailing: ToggleButtons( + child: Center( + child: ToggleButtons( isSelected: isSelected, onPressed: (int newIndex) { ref.read(copyFormatPod.notifier).state = diff --git a/example/lib/demo/screens/color_picker/picker_toggle_buttons/pickers_enabled_switch.dart b/example/lib/demo/screens/color_picker/picker_toggle_buttons/pickers_enabled_switch.dart index a903532..465bf4b 100644 --- a/example/lib/demo/screens/color_picker/picker_toggle_buttons/pickers_enabled_switch.dart +++ b/example/lib/demo/screens/color_picker/picker_toggle_buttons/pickers_enabled_switch.dart @@ -31,42 +31,40 @@ class PickersEnabledSwitch extends ConsumerWidget { condition: ref.watch(enableTooltipsPod), tooltip: 'ColorPicker(pickersEnabled:\n' ' ${ref.read(pickersEnabledPod)})', - child: ListTile( - trailing: ToggleButtons( - isSelected: isSelected, - onPressed: (int index) { - isSelected[index] = !isSelected[index]; - // If 'Both' turned ON, then 'primary' and 'Accent' is OFF. - if (index == 0 && isSelected[0]) { - isSelected[1] = false; - isSelected[2] = false; - } - // If 'primary' turned ON, then 'Both' is turned OFF. - if (index == 1 && isSelected[1]) isSelected[0] = false; - // If 'accent' turned ON, then 'Both' is turned OFF. - if (index == 2 && isSelected[2]) isSelected[0] = false; - // Assign new state to enabled pickers. - ref.read(pickersEnabledPod.notifier).state = - { - ColorPickerType.both: isSelected[0], - ColorPickerType.primary: isSelected[1], - ColorPickerType.accent: isSelected[2], - ColorPickerType.bw: isSelected[3], - ColorPickerType.custom: isSelected[4], - ColorPickerType.customSecondary: isSelected[5], - ColorPickerType.wheel: isSelected[6], - }; - }, - children: const [ - Text('P & A', style: TextStyle(fontSize: _kToggleFontSize)), - Text('Primary', style: TextStyle(fontSize: _kToggleFontSize)), - Text('Accent', style: TextStyle(fontSize: _kToggleFontSize)), - Text('B & W', style: TextStyle(fontSize: _kToggleFontSize)), - Text('Custom', style: TextStyle(fontSize: _kToggleFontSize)), - Text('Option', style: TextStyle(fontSize: _kToggleFontSize)), - Text('Wheel', style: TextStyle(fontSize: _kToggleFontSize)), - ], - ), + child: ToggleButtons( + isSelected: isSelected, + onPressed: (int index) { + isSelected[index] = !isSelected[index]; + // If 'Both' turned ON, then 'primary' and 'Accent' is OFF. + if (index == 0 && isSelected[0]) { + isSelected[1] = false; + isSelected[2] = false; + } + // If 'primary' turned ON, then 'Both' is turned OFF. + if (index == 1 && isSelected[1]) isSelected[0] = false; + // If 'accent' turned ON, then 'Both' is turned OFF. + if (index == 2 && isSelected[2]) isSelected[0] = false; + // Assign new state to enabled pickers. + ref.read(pickersEnabledPod.notifier).state = + { + ColorPickerType.both: isSelected[0], + ColorPickerType.primary: isSelected[1], + ColorPickerType.accent: isSelected[2], + ColorPickerType.bw: isSelected[3], + ColorPickerType.custom: isSelected[4], + ColorPickerType.customSecondary: isSelected[5], + ColorPickerType.wheel: isSelected[6], + }; + }, + children: const [ + Text('P & A', style: TextStyle(fontSize: _kToggleFontSize)), + Text('Primary', style: TextStyle(fontSize: _kToggleFontSize)), + Text('Accent', style: TextStyle(fontSize: _kToggleFontSize)), + Text('B & W', style: TextStyle(fontSize: _kToggleFontSize)), + Text('Custom', style: TextStyle(fontSize: _kToggleFontSize)), + Text('Option', style: TextStyle(fontSize: _kToggleFontSize)), + Text('Wheel', style: TextStyle(fontSize: _kToggleFontSize)), + ], ), ), ], From c37a93e8edb50c3ccc1690c5ccc0b45b4ad0893b Mon Sep 17 00:00:00 2001 From: rydmike Date: Fri, 13 Dec 2024 22:53:36 +0200 Subject: [PATCH 22/24] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 065100a..309e3bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,11 @@ All notable changes to the **FlexColorPicker** package are documented in this fi * Updated the package to support and require min Flutter v3.27.0. * Fixed all new analyzer lint warnings and removed usage of all deprecated `Color` properties. - * While the package now uses the updated `Color` class with support for wide gamut, the color inputs and outputs are still 32-bit RGB color values. A future update may add support for more and new color formats. + * While the package now uses the updated `Color` class with support for wide color gamut, the color inputs and outputs are still 32-bit RGB color values. A future feature update may add support for more and new color formats. +**KNOWN ISSUES** + +* There style breaking issue on the padding around the custom opacity `Slider`. The thumb also jumps towards the center when pressed. These issues did not exist in Flutter 3.24.x and earlier versions. It seems like the issue cannot be completely solved in custom Slider implementation. The extra padding and thumb jumping towards the center seem related to `Slider` changes introduced in Flutter 3.27.0. Those changes were made in preparation for releasing support for the updated Material-3 slider styles. For more information, see issue https://github.com/rydmike/flex_color_picker/issues/90. A fix in Flutter SDK may be needed to solve this issue. ## 3.6.0 From e5f072a0411448714c16c125418232acabcee8ad Mon Sep 17 00:00:00 2001 From: rydmike Date: Sat, 28 Dec 2024 22:34:15 +0200 Subject: [PATCH 23/24] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 309e3bc..0c6566e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,11 @@ All notable changes to the **FlexColorPicker** package are documented in this fi ## 3.7.0 -**Dec 13, 2024** +**Dec 28, 2024** **PACKAGE** -* Updated the package to support and require min Flutter v3.27.0. +* Updated the package to support and require at least Flutter v3.27.0. * Fixed all new analyzer lint warnings and removed usage of all deprecated `Color` properties. * While the package now uses the updated `Color` class with support for wide color gamut, the color inputs and outputs are still 32-bit RGB color values. A future feature update may add support for more and new color formats. From f2c86a1012e9585f346f86a3b440735f93f1ebb3 Mon Sep 17 00:00:00 2001 From: rydmike Date: Sun, 29 Dec 2024 00:24:19 +0200 Subject: [PATCH 24/24] Chore: Update to RydMike lints 2.3.0 and fix lints --- CHANGELOG.md | 2 +- analysis_options.yaml | 77 ++++++++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c6566e..d34332b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the **FlexColorPicker** package are documented in this fi ## 3.7.0 -**Dec 28, 2024** +**Dec 29, 2024** **PACKAGE** diff --git a/analysis_options.yaml b/analysis_options.yaml index a7e3cdc..900d461 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. #