Skip to content

Commit

Permalink
Cleaning: Hashcode algo changed. Remove not needed finals.
Browse files Browse the repository at this point in the history
* Lint: Remove not needed finals.
* HasCode: Change to Object.hash (used jenkins deprecated in master).
  • Loading branch information
rydmike committed Jul 8, 2022
1 parent aabfde5 commit ca72786
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 149 deletions.
7 changes: 0 additions & 7 deletions example/lib/example5/widgets/shared/color_picker_inkwell.dart
Expand Up @@ -225,13 +225,6 @@ class ColorPickerInkWell extends StatelessWidget {
final bool isLight = Theme.of(context).brightness == Brightness.light;

return InkWell(
// TODO(rydmike): Remove this commented customized InkWell style.
// We want a bit more pronounced hover color for this case than normally.
// hoverColor: isLight ? const Color(0x40BCBCBC):const Color(0x30FFFFFF),
// splashColor: isLight ? const Color(0x40BCBCBC):const Color(0x30FFFFFF),
// focusColor: isLight ? const Color(0x40BCBCBC):const Color(0x30FFFFFF),
// highlightColor:
// isLight ? const Color(0x40BCBCBC) : const Color(0x30FFFFFF),
onHover: (bool value) {
onHover?.call(value);
},
Expand Down
2 changes: 1 addition & 1 deletion example/macos/Podfile.lock
Expand Up @@ -24,7 +24,7 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos

SPEC CHECKSUMS:
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
shared_preferences_macos: a64dc611287ed6cbe28fd1297898db1336975727
url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3
Expand Down
24 changes: 12 additions & 12 deletions lib/src/flex_color_scheme.dart
Expand Up @@ -5711,15 +5711,15 @@ class FlexColorScheme with Diagnosticable {
// - If neither was given we use the surface color in dark mode and
// primary color in light mode, the same logic that Flutter SDK
// ThemeData.from factory sets the AppBar background color to.
final Color effectiveAppBarColor = appBarBackground ??
final Color effectiveAppBarBackgroundColor = appBarBackground ??
(useSubThemes && subTheme.appBarBackgroundSchemeColor != null
? FlexSubThemes.schemeColor(
subTheme.appBarBackgroundSchemeColor!, colorScheme)
: isDark
? colorScheme.surface
: colorScheme.primary);
final Brightness appBarBrightness =
ThemeData.estimateBrightnessForColor(effectiveAppBarColor);
ThemeData.estimateBrightnessForColor(effectiveAppBarBackgroundColor);
Color appBarForeground =
appBarBrightness == Brightness.dark ? Colors.white : Colors.black;
// Icons are slightly black transparent in light mode! This per SDK.
Expand All @@ -5729,10 +5729,10 @@ class FlexColorScheme with Diagnosticable {
if (useSubThemes && subTheme.blendTextTheme) {
if (appBarBrightness == Brightness.dark) {
appBarForeground =
FlexColor.lightSurface.blend(effectiveAppBarColor, 12);
FlexColor.lightSurface.blend(effectiveAppBarBackgroundColor, 12);
} else {
appBarForeground =
FlexColor.darkSurface.blend(effectiveAppBarColor, 12);
FlexColor.darkSurface.blend(effectiveAppBarBackgroundColor, 12);
}
appBarIconColor = appBarForeground;
}
Expand All @@ -5751,7 +5751,7 @@ class FlexColorScheme with Diagnosticable {
? Colors.black87
: Colors.white;
case FlexTabBarStyle.universal:
// TODO(rydmike): Need better FlexTabBarStyle.universal algo some day.
// TODO(rydmike): Chore: Better FlexTabBarStyle.universal algo.
return isDark
? colorScheme.primary.blendAlpha(Colors.white, 0xE6) // 90%
: colorScheme.primary.blendAlpha(Colors.white, 0xB2); // 50%
Expand All @@ -5773,9 +5773,9 @@ class FlexColorScheme with Diagnosticable {
: colorScheme.onSurface.withAlpha(0x99); // 60%
case FlexTabBarStyle.forAppBar:
return (appBarBrightness == Brightness.light &&
(effectiveAppBarColor == Colors.white ||
effectiveAppBarColor == colorScheme.surface ||
effectiveAppBarColor == colorScheme.background))
(effectiveAppBarBackgroundColor == Colors.white ||
effectiveAppBarBackgroundColor == colorScheme.surface ||
effectiveAppBarBackgroundColor == colorScheme.background))
? colorScheme.onSurface.withAlpha(0x99) // 60%
: selectedTabColor().withAlpha(0xB2); // 70% alpha
case FlexTabBarStyle.universal:
Expand Down Expand Up @@ -6047,7 +6047,7 @@ class FlexColorScheme with Diagnosticable {
// The FlexColorScheme implementation below has been changed to
// use these new AppBarTheme features in version 2.0.0.
appBarTheme: AppBarTheme(
backgroundColor: effectiveAppBarColor,
backgroundColor: effectiveAppBarBackgroundColor,
foregroundColor: appBarForeground,
iconTheme: IconThemeData(color: appBarIconColor),
actionsIconTheme: IconThemeData(color: appBarIconColor),
Expand Down Expand Up @@ -6140,7 +6140,7 @@ class FlexColorScheme with Diagnosticable {
subTheme.tabBarItemSchemeColor!, colorScheme)
.withAlpha(0x99) // 60%,
),
// Set colors for for icons in opted in sub themes.
// Set colors for icons in opted in sub themes.
iconTheme: useSubThemes
? IconThemeData(color: effectiveTextTheme.headline6!.color)
: null,
Expand Down Expand Up @@ -6930,7 +6930,7 @@ class FlexColorScheme with Diagnosticable {

/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => hashList(<Object?>[
int get hashCode => Object.hashAll(<Object?>[
colorScheme,
brightness,
primary,
Expand Down Expand Up @@ -7465,7 +7465,7 @@ class FlexSchemeSurfaceColors with Diagnosticable {

/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
surface,
surfaceVariant,
inverseSurface,
Expand Down
22 changes: 10 additions & 12 deletions lib/src/flex_key_color.dart
@@ -1,5 +1,3 @@
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:material_color_utilities/material_color_utilities.dart';

Expand Down Expand Up @@ -107,15 +105,15 @@ class FlexKeyColors with Diagnosticable {
/// FlexColorSchemes, while still passing in a configuration object with
/// other properties set, that have no effect if [useKeyColors] is false.
const FlexKeyColors({
final this.useKeyColors = true,
final this.useSecondary = false,
final this.useTertiary = false,
final this.keepPrimary = false,
final this.keepSecondary = false,
final this.keepTertiary = false,
final this.keepPrimaryContainer = false,
final this.keepSecondaryContainer = false,
final this.keepTertiaryContainer = false,
this.useKeyColors = true,
this.useSecondary = false,
this.useTertiary = false,
this.keepPrimary = false,
this.keepSecondary = false,
this.keepTertiary = false,
this.keepPrimaryContainer = false,
this.keepSecondaryContainer = false,
this.keepTertiaryContainer = false,
});

/// Turn on using Material 3 key color based [TonalPalette] colors for the
Expand Down Expand Up @@ -335,7 +333,7 @@ class FlexKeyColors with Diagnosticable {

/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
useKeyColors,
useSecondary,
useTertiary,
Expand Down
12 changes: 6 additions & 6 deletions lib/src/flex_scheme_color.dart
Expand Up @@ -36,15 +36,15 @@ class FlexSchemeColor with Diagnosticable {
/// The appBarColor and error colors are not required, if they
/// are null, they will be provided by defaults in theme creation later.
const FlexSchemeColor({
required final this.primary,
required this.primary,
Color? primaryContainer,
required final this.secondary,
required this.secondary,
Color? secondaryContainer,
Color? tertiary,
Color? tertiaryContainer,
final this.appBarColor,
final this.error,
final this.errorContainer,
this.appBarColor,
this.error,
this.errorContainer,
@Deprecated('Use primaryContainer instead. '
'In FlexSchemeColor old primaryContainer built-in colors were moved to '
'the primaryContainer color since their design fitted that role best. '
Expand Down Expand Up @@ -619,7 +619,7 @@ class FlexSchemeColor with Diagnosticable {

/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
primary,
primaryContainer,
secondary,
Expand Down
12 changes: 5 additions & 7 deletions lib/src/flex_scheme_data.dart
@@ -1,5 +1,3 @@
import 'dart:ui';

import 'package:flutter/foundation.dart';

import 'flex_scheme_color.dart';
Expand Down Expand Up @@ -27,10 +25,10 @@ class FlexSchemeData with Diagnosticable {
///
/// Contains [name], [description] plus [light] and [dark] scheme colors.
const FlexSchemeData({
required final this.name,
required final this.description,
required final this.light,
required final this.dark,
required this.name,
required this.description,
required this.light,
required this.dark,
});

/// A short name for the [FlexSchemeData] based color scheme.
Expand Down Expand Up @@ -74,7 +72,7 @@ class FlexSchemeData with Diagnosticable {

/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
name,
description,
light,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/flex_scheme_on_colors.dart
Expand Up @@ -303,7 +303,7 @@ class FlexSchemeOnColors with Diagnosticable {

/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
onPrimary,
onPrimaryContainer,
onSecondary,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/flex_sub_themes_data.dart
Expand Up @@ -2298,7 +2298,7 @@ class FlexSubThemesData with Diagnosticable {

/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => hashList(<Object?>[
int get hashCode => Object.hashAll(<Object?>[
interactionEffects,
blendOnLevel,
blendOnColors,
Expand Down
102 changes: 51 additions & 51 deletions lib/src/flex_theme_mode_switch.dart
Expand Up @@ -46,34 +46,34 @@ class FlexThemeModeSwitch extends StatelessWidget {
/// Default constructor.
const FlexThemeModeSwitch({
super.key,
required final this.themeMode,
required final this.onThemeModeChanged,
required final this.flexSchemeData,
final this.title,
final this.hasTitle = true,
final this.labelLight = 'LIGHT',
final this.labelDark = 'DARK',
final this.labelSystem = 'SYSTEM',
final this.showSystemMode = true,
final this.buttonOrder = FlexThemeModeButtonOrder.lightDarkSystem,
final this.selectedLabelStyle,
final this.unselectedLabelStyle,
final this.labelAbove = true,
final this.backgroundLight,
final this.backgroundDark,
final this.backgroundSystem,
final this.selectedBorder,
final this.unselectedBorder,
final this.selectedElevation = 0,
final this.unselectedElevation = 0,
final this.optionButtonPadding,
final this.optionButtonMargin,
final this.optionButtonBorderRadius = 5,
final this.height = 24,
final this.width = 24,
final this.borderRadius = 4,
final this.padding,
final this.hoverColor,
required this.themeMode,
required this.onThemeModeChanged,
required this.flexSchemeData,
this.title,
this.hasTitle = true,
this.labelLight = 'LIGHT',
this.labelDark = 'DARK',
this.labelSystem = 'SYSTEM',
this.showSystemMode = true,
this.buttonOrder = FlexThemeModeButtonOrder.lightDarkSystem,
this.selectedLabelStyle,
this.unselectedLabelStyle,
this.labelAbove = true,
this.backgroundLight,
this.backgroundDark,
this.backgroundSystem,
this.selectedBorder,
this.unselectedBorder,
this.selectedElevation = 0,
this.unselectedElevation = 0,
this.optionButtonPadding,
this.optionButtonMargin,
this.optionButtonBorderRadius = 5,
this.height = 24,
this.width = 24,
this.borderRadius = 4,
this.padding,
this.hoverColor,
}) : assert(selectedElevation >= 0.0, 'Selected elevation must be >= 0.0'),
assert(
unselectedElevation >= 0.0, 'Unselected elevation must be >= 0.0');
Expand Down Expand Up @@ -342,24 +342,24 @@ class FlexThemeModeOptionButton extends StatelessWidget {
/// Default constructor.
const FlexThemeModeOptionButton({
super.key,
required final this.flexSchemeColor,
final this.backgroundColor,
final this.label,
final this.labelStyle,
final this.labelAbove = true,
required final this.selected,
final this.onSelect,
final this.selectedBorder,
final this.unselectedBorder,
final this.elevation = 0,
final this.optionButtonPadding,
final this.optionButtonMargin,
final this.optionButtonBorderRadius = 5,
final this.height = 24,
final this.width = 24,
final this.borderRadius = 4,
final this.padding,
final this.hoverColor,
required this.flexSchemeColor,
this.backgroundColor,
this.label,
this.labelStyle,
this.labelAbove = true,
required this.selected,
this.onSelect,
this.selectedBorder,
this.unselectedBorder,
this.elevation = 0,
this.optionButtonPadding,
this.optionButtonMargin,
this.optionButtonBorderRadius = 5,
this.height = 24,
this.width = 24,
this.borderRadius = 4,
this.padding,
this.hoverColor,
}) : assert(elevation >= 0.0, 'Elevation must be >= 0.0');

/// The scheme colors used to colorize the option button's four colors.
Expand Down Expand Up @@ -551,11 +551,11 @@ class FlexThemeModeOptionButton extends StatelessWidget {
class _SchemeColorBox extends StatelessWidget {
/// Default constructor.
const _SchemeColorBox({
required final this.color,
final this.height = 24,
final this.width = 24,
final this.borderRadius = 4,
final this.padding,
required this.color,
this.height = 24,
this.width = 24,
this.borderRadius = 4,
this.padding,
});

/// The background color used to draw an individual scheme color box.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/flex_tones.dart
Expand Up @@ -676,7 +676,7 @@ class FlexTones with Diagnosticable {

/// Override for hashcode, dart.ui Jenkins based.
@override
int get hashCode => hashList(<Object?>[
int get hashCode => Object.hashAll(<Object?>[
primaryTone,
onPrimaryTone,
primaryContainerTone,
Expand Down

0 comments on commit ca72786

Please sign in to comment.