Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.5.0 for Flutter 3.27 #21

Merged
merged 12 commits into from
Dec 28, 2024
8 changes: 8 additions & 0 deletions .run/Run ALL tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run ALL tests" type="FlutterTestConfigType" factoryName="Flutter Test" singleton="false">
<option name="testDir" value="$PROJECT_DIR$/test" />
<option name="useRegexp" value="false" />
<option name="additionalArgs" value="" />
<method v="2" />
</configuration>
</component>
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to the **FlexSeedScheme** (FSS) package are documented here.

## 3.5.0

**Dec 29, 2024**

**PACKAGE**

* 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.


## 3.4.1

**Sep 25, 2024**
Expand Down
24 changes: 23 additions & 1 deletion all_lint_rules.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# 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
Expand All @@ -23,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
Expand Down Expand Up @@ -70,6 +87,7 @@ linter:
- directives_ordering
- discarded_futures
- do_not_use_environment
- document_ignores
- empty_catches
- empty_constructor_bodies
- empty_statements
Expand All @@ -82,6 +100,7 @@ linter:
- implicit_call_tearoffs
- implicit_reopen
- invalid_case_patterns
- invalid_runtime_check_with_js_interop_types
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_annotations
Expand All @@ -108,6 +127,7 @@ linter:
- 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
Expand Down Expand Up @@ -166,13 +186,15 @@ 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
- type_annotate_public_apis
- 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
Expand Down Expand Up @@ -200,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
Expand All @@ -220,5 +241,6 @@ linter:
- use_super_parameters
- use_test_throws_matchers
- use_to_and_as_if_applicable
- use_truncating_division
- valid_regexps
- void_checks
140 changes: 102 additions & 38 deletions analysis_options.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/
**.fvm/
.fvm
Expand Down
22 changes: 18 additions & 4 deletions example/lib/core/constants/app_data.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

/// App static functions and constants used in the example applications.
Expand All @@ -14,7 +15,10 @@ sealed class AppData {
// belongs and no need to put it as a const somewhere and no need to pass it
// around via a title prop either. Also used in the About box as app name.
static String title(BuildContext context) =>
(context as Element).findAncestorWidgetOfExactType<MaterialApp>()!.title;
(context as Element)
.findAncestorWidgetOfExactType<MaterialApp>()!
.title ??
'';

// When building new public web versions of the demos, make sure to
// update this info before triggering GitHub actions CI/CD that builds them.
Expand All @@ -23,15 +27,25 @@ sealed class AppData {
static const String packageName = 'FlexSeed\u{00AD}Scheme';
// Version of the WEB build, usually same as package, but it also has a
// build numbers.

// 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 versionMajor = '3';
static const String versionMinor = '4';
static const String versionPatch = '1';
static const String versionMinor = '5';
static const String versionPatch = '0';
static const String versionBuild = '01';
static const String version = '$versionMajor.$versionMinor.$versionPatch '
'Build-$versionBuild';
static const String packageVersion =
'$versionMajor.$versionMinor.$versionPatch';
static const String flutterVersion = '3.24.3 (canvaskit)';
static const String flutterVersion = '3.27.5 (canvaskit$buildType)';
static const String copyright = '© 2022-2024';
static const String author = 'Mike Rydstrom';
static const String license = 'BSD 3-Clause License';
Expand Down
62 changes: 56 additions & 6 deletions example/lib/core/utils/flex_color_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ extension FlexColorExtensions on Color {
if (amount <= 0) return this;
if (amount > 100) return Colors.white;
final Color color = Color.fromARGB(
alpha,
math.max(0, math.min(255, red - (255 * -(amount / 100)).round())),
math.max(0, math.min(255, green - (255 * -(amount / 100)).round())),
math.max(0, math.min(255, blue - (255 * -(amount / 100)).round())),
alpha8bit,
math.max(0, math.min(255, red8bit - (255 * -(amount / 100)).round())),
math.max(0, math.min(255, green8bit - (255 * -(amount / 100)).round())),
math.max(0, math.min(255, blue8bit - (255 * -(amount / 100)).round())),
);
return color;
}
Expand Down Expand Up @@ -54,13 +54,63 @@ extension FlexColorExtensions on Color {

/// Return uppercase Flutter style hex code string of the color.
String get hexCode {
return value.toRadixString(16).toUpperCase().padLeft(8, '0');
return value32bit.toRadixString(16).toUpperCase().padLeft(8, '0');
}

/// Return uppercase RGB hex code string, with # and no alpha value.
/// This format is often used in APIs and in CSS color values..
String get hex {
// ignore: lines_longer_than_80_chars
return '#${value.toRadixString(16).toUpperCase().padLeft(8, '0').substring(2)}';
return '#${value32bit.toRadixString(16).toUpperCase().padLeft(8, '0').substring(2)}';
}

/// A 32 bit value representing this color.
///
/// This feature brings back the Color.value32bit 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 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
/// 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;
}
}
2 changes: 1 addition & 1 deletion example/lib/core/views/app/color_picker_inkwell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class ColorPickerInkWellDialog extends StatelessWidget {
if (await colorPicker.showPickerDialog(
context,
insetPadding: const EdgeInsets.all(16),
barrierColor: Colors.black.withOpacity(0.05),
barrierColor: Colors.black.withValues(alpha: 0.05),
constraints: const BoxConstraints(
minHeight: 570,
minWidth: 450,
Expand Down
4 changes: 2 additions & 2 deletions example/lib/core/views/universal/color_scheme_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class ColorSchemeBox extends StatelessWidget {

// On color for icon on the colored box.
static Color _onColor(final Color color) => _isLight(color)
? Colors.black.withOpacity(0.4)
: Colors.white.withOpacity(0.4);
? Colors.black.withValues(alpha: 0.4)
: Colors.white.withValues(alpha: 0.4);

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions example/lib/core/views/universal/showcase_material.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4721,8 +4721,8 @@ class _SnackBarShowcaseState extends State<SnackBarShowcase> {
final Color defaultBackgroundColor = isLight
? useMaterial3
? colorScheme.inverseSurface
: Color.alphaBlend(
colorScheme.onSurface.withOpacity(0.80), colorScheme.surface)
: Color.alphaBlend(colorScheme.onSurface.withValues(alpha: 0.80),
colorScheme.surface)
: colorScheme.onSurface;
final Color snackBackground =
theme.snackBarTheme.backgroundColor ?? defaultBackgroundColor;
Expand Down
21 changes: 13 additions & 8 deletions example/lib/home/views/widgets/show_tonal_palette.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flex_seed_scheme/flex_seed_scheme.dart';
import 'package:flutter/material.dart';

import '../../../core/utils/effective_flex_tones.dart';
import '../../../core/utils/flex_color_extension.dart';
import '../../../theme/controllers/theme_controller.dart';
import 'select_palette_type.dart';
import 'tonal_palette_colors.dart';
Expand Down Expand Up @@ -80,19 +81,23 @@ class ShowTonalPalette extends StatelessWidget {
} else {
// Get FlexCorePalette tones if using FlexTone
final FlexCorePalette palettes = FlexCorePalette.fromSeeds(
primary: controller.primarySeedColor.value,
primary: controller.primarySeedColor.value32bit,
// Pass in null if set to not use secondary or tertiary seed keys.
secondary: controller.useSecondaryKey
? controller.secondarySeedColor.value
? controller.secondarySeedColor.value32bit
: null,
tertiary: controller.useTertiaryKey
? controller.tertiarySeedColor.value
? controller.tertiarySeedColor.value32bit
: null,
error: controller.useErrorKey
? controller.errorSeedColor.value32bit
: null,
neutral: controller.useNeutralKey
? controller.neutralSeedColor.value32bit
: null,
neutralVariant: controller.useNeutralKey
? controller.neutralSeedColor.value32bit
: null,
error: controller.useErrorKey ? controller.errorSeedColor.value : null,
neutral:
controller.useNeutralKey ? controller.neutralSeedColor.value : null,
neutralVariant:
controller.useNeutralKey ? controller.neutralSeedColor.value : null,
// Tone config details we get from active FlexTones.
primaryChroma: tones.primaryChroma,
primaryMinChroma: tones.primaryMinChroma,
Expand Down
4 changes: 2 additions & 2 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404

PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
4 changes: 4 additions & 0 deletions example/macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
Loading
Loading