Skip to content

Commit

Permalink
feat(sdk)!: update dependency flutter to v3.22.0 and remove deprecate…
Browse files Browse the repository at this point in the history
…d theme options (#1215)

* feat(sdk): update dependency flutter to v3.22.0

* chore(deps): dependencies maintenance

* fix: clean up deprecated member usages and migrate to `device_preview_plus`

* chore: update supported flutter version to `3.22.0+` on home page

* style: fix formatting

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <renovate[bot]@users.noreply.github.com>
Co-authored-by: Joshua Tang <[email protected]>
  • Loading branch information
3 people authored May 26, 2024
1 parent 874a8fb commit cea3e6f
Show file tree
Hide file tree
Showing 44 changed files with 319 additions and 406 deletions.
2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.19.6",
"flutterSdkVersion": "3.22.0",
"flavors": {}
}
27 changes: 14 additions & 13 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.1"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -214,10 +214,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -315,10 +315,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -347,10 +347,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "14.2.1"
web:
dependency: transitive
description:
Expand All @@ -368,4 +368,5 @@ packages:
source: hosted
version: "3.0.3"
sdks:
dart: ">=3.2.0 <4.0.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
17 changes: 2 additions & 15 deletions lib/basic_theme/cubit/basic_theme_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,6 @@ class BasicThemeCubit extends Cubit<BasicThemeState> {
emit(state.copyWith(colorScheme: colorScheme));
}

void backgroundColorChanged(Color color) {
final colorScheme = state.colorScheme.copyWith(
background: color,
onBackground: _service.getOnNeutralColor(color),
);
emit(state.copyWith(colorScheme: colorScheme));
}

void onBackgroundColorChanged(Color color) {
final colorScheme = state.colorScheme.copyWith(onBackground: color);
emit(state.copyWith(colorScheme: colorScheme));
}

void surfaceColorChanged(Color color) {
final colorScheme = state.colorScheme.copyWith(
surface: color,
Expand All @@ -193,9 +180,9 @@ class BasicThemeCubit extends Cubit<BasicThemeState> {
emit(state.copyWith(colorScheme: colorScheme));
}

void surfaceVariantColorChanged(Color color) {
void surfaceContainerHighestColorChanged(Color color) {
final colorScheme = state.colorScheme.copyWith(
surfaceVariant: color,
surfaceContainerHighest: color,
onSurfaceVariant: _service.getOnSurfaceVariantColor(color),
);
emit(state.copyWith(colorScheme: colorScheme));
Expand Down
6 changes: 2 additions & 4 deletions lib/basic_theme/cubit/basic_theme_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BasicThemeState extends Equatable {
Color? onBackground,
Color? surface,
Color? onSurface,
Color? surfaceVariant,
Color? surfaceContainerHighest,
Color? onSurfaceVariant,
Color? outline,
Color? shadow,
Expand All @@ -67,11 +67,9 @@ class BasicThemeState extends Equatable {
onError: onError,
errorContainer: errorContainer,
onErrorContainer: onErrorContainer,
background: background,
onBackground: onBackground,
surface: surface,
onSurface: onSurface,
surfaceVariant: surfaceVariant,
surfaceContainerHighest: surfaceContainerHighest,
onSurfaceVariant: onSurfaceVariant,
outline: outline,
shadow: shadow,
Expand Down
24 changes: 5 additions & 19 deletions lib/basic_theme/view/basic_theme_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,6 @@ class _NeutralColorPickers extends StatelessWidget {
return MaterialStatesCard<Color>(
header: 'Neutral colors',
items: [
MaterialStateItem(
key: const Key('basicThemeEditor_backgroundColorPicker'),
title: 'Background',
tooltip: BasicThemeDocs.background,
value: colorScheme.background,
onValueChanged: cubit.backgroundColorChanged,
),
MaterialStateItem(
key: const Key('basicThemeEditor_onBackgroundColorPicker'),
title: 'On background',
tooltip: BasicThemeDocs.onBackground,
value: colorScheme.onBackground,
onValueChanged: cubit.onBackgroundColorChanged,
),
MaterialStateItem(
key: const Key('basicThemeEditor_surfaceColorPicker'),
title: 'Surface',
Expand Down Expand Up @@ -270,11 +256,11 @@ class _NeutralVariantColorPickers extends StatelessWidget {
header: 'Neutral variant colors',
items: [
MaterialStateItem(
key: const Key('basicThemeEditor_surfaceVariantColorPicker'),
title: 'Surface variant',
tooltip: BasicThemeDocs.surfaceVariant,
value: colorScheme.surfaceVariant,
onValueChanged: cubit.surfaceVariantColorChanged,
key: const Key('basicThemeEditor_surfaceContainerHighestColorPicker'),
title: 'Surface container highest',
tooltip: BasicThemeDocs.surfaceContainerHighest,
value: colorScheme.surfaceContainerHighest,
onValueChanged: cubit.surfaceContainerHighestColorChanged,
),
MaterialStateItem(
key: const Key('basicThemeEditor_onSurfaceVariantColorPicker'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _BackgroundColorPicker extends StatelessWidget {
.theme
.backgroundColor;
final themeBackgroundColor =
context.watch<ColorThemeCubit>().state.colorScheme.background;
context.watch<ColorThemeCubit>().state.colorScheme.surface;

return ColorListTile(
key: const Key('bottomNavigationBarThemeEditor_backgroundColorPicker'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ abstract class AbstractButtonStyleCubit extends Cubit<ButtonStyleState> {

void shadowColorChanged(Color color) {
emitWithButtonStyle(
style.copyWith(shadowColor: MaterialStateProperty.all(color)),
style.copyWith(shadowColor: WidgetStateProperty.all(color)),
);
}

Expand All @@ -89,7 +89,7 @@ abstract class AbstractButtonStyleCubit extends Cubit<ButtonStyleState> {
if (border != null) {
emitWithButtonStyle(
style.copyWith(
shape: MaterialStateProperty.all(border),
shape: WidgetStateProperty.all(border),
),
);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ abstract class AbstractButtonStyleCubit extends Cubit<ButtonStyleState> {
if (newBorder != null) {
emitWithButtonStyle(
style.copyWith(
shape: MaterialStateProperty.all(newBorder),
shape: WidgetStateProperty.all(newBorder),
),
);
}
Expand All @@ -131,34 +131,34 @@ abstract class AbstractButtonStyleCubit extends Cubit<ButtonStyleState> {
emit(state.copyWith(style: style));
}

MaterialStateProperty<Color?> getBasicColor(
MaterialStateProperty<Color?> color, {
WidgetStateProperty<Color?> getBasicColor(
WidgetStateProperty<Color?> color, {
Color? defaultColor,
Color? disabledColor,
}) {
return MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled)) {
return disabledColor ?? color.resolve({MaterialState.disabled});
return WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.disabled)) {
return disabledColor ?? color.resolve({WidgetState.disabled});
}
return defaultColor ?? color.resolve({});
});
}

MaterialStateProperty<Color?> _getOverlayColor(
MaterialStateProperty<Color?> overlayColor, {
WidgetStateProperty<Color?> _getOverlayColor(
WidgetStateProperty<Color?> overlayColor, {
Color? hoveredColor,
Color? focusedColor,
Color? pressedColor,
}) {
return MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.hovered)) {
return hoveredColor ?? overlayColor.resolve({MaterialState.hovered});
return WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.hovered)) {
return hoveredColor ?? overlayColor.resolve({WidgetState.hovered});
}
if (states.contains(MaterialState.focused)) {
return focusedColor ?? overlayColor.resolve({MaterialState.focused});
if (states.contains(WidgetState.focused)) {
return focusedColor ?? overlayColor.resolve({WidgetState.focused});
}
if (states.contains(MaterialState.pressed)) {
return pressedColor ?? overlayColor.resolve({MaterialState.pressed});
if (states.contains(WidgetState.pressed)) {
return pressedColor ?? overlayColor.resolve({WidgetState.pressed});
}
return null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class ButtonStyleState extends Equatable {
const ButtonStyleState({this.style});

factory ButtonStyleState.withStyle({
MaterialStateProperty<Color?>? backgroundColor,
MaterialStateProperty<Color?>? foregroundColor,
MaterialStateProperty<Color?>? overlayColor,
MaterialStateProperty<Color?>? shadowColor,
MaterialStateProperty<double?>? elevation,
MaterialStateProperty<OutlinedBorder?>? shape,
WidgetStateProperty<Color?>? backgroundColor,
WidgetStateProperty<Color?>? foregroundColor,
WidgetStateProperty<Color?>? overlayColor,
WidgetStateProperty<Color?>? shadowColor,
WidgetStateProperty<double?>? elevation,
WidgetStateProperty<OutlinedBorder?>? shape,
}) {
return ButtonStyleState(
style: ButtonStyle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ abstract class AbstractButtonStyleEditor<T extends AbstractButtonStyleCubit>
MaterialStateItem(
key: const Key('abstractButtonStyleEditor_foregroundColor_disabled'),
title: 'Disabled',
value: color?.resolve({MaterialState.disabled}) ??
value: color?.resolve({WidgetState.disabled}) ??
fallbackForegroundDisabledColor(colorScheme),
onValueChanged: cubit.foregroundDisabledColorChanged,
),
Expand All @@ -119,21 +119,21 @@ abstract class AbstractButtonStyleEditor<T extends AbstractButtonStyleCubit>
MaterialStateItem(
key: const Key('abstractButtonStyleEditor_overlayColor_hovered'),
title: 'Hovered',
value: color?.resolve({MaterialState.hovered}) ??
value: color?.resolve({WidgetState.hovered}) ??
fallbackOverlayHoveredColor(colorScheme),
onValueChanged: cubit.overlayHoveredColorChanged,
),
MaterialStateItem(
key: const Key('abstractButtonStyleEditor_overlayColor_focused'),
title: 'Focused',
value: color?.resolve({MaterialState.focused}) ??
value: color?.resolve({WidgetState.focused}) ??
fallbackOverlayFocusedColor(colorScheme),
onValueChanged: cubit.overlayFocusedColorChanged,
),
MaterialStateItem(
key: const Key('abstractButtonStyleEditor_overlayColor_pressed'),
title: 'Pressed',
value: color?.resolve({MaterialState.pressed}) ??
value: color?.resolve({WidgetState.pressed}) ??
fallbackOverlayPressedColor(colorScheme),
onValueChanged: cubit.overlayPressedColorChanged,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ abstract class AbstractFlatButtonStyleCubit extends AbstractButtonStyleCubit {

void backgroundColorChanged(Color color) {
emitWithButtonStyle(
style.copyWith(backgroundColor: MaterialStateProperty.all(color)),
style.copyWith(backgroundColor: WidgetStateProperty.all(color)),
);
}

void elevationChanged(String value) {
final elevation = double.tryParse(value);
if (elevation != null) {
emitWithButtonStyle(
style.copyWith(elevation: MaterialStateProperty.all(elevation)),
style.copyWith(elevation: WidgetStateProperty.all(elevation)),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,27 @@ class ElevatedButtonThemeCubit extends AbstractButtonStyleCubit {
}
}

MaterialStateProperty<double?> _getElevation(
MaterialStateProperty<double?> elevation, {
WidgetStateProperty<double?> _getElevation(
WidgetStateProperty<double?> elevation, {
double? defaultElevation,
double? disabledElevation,
double? hoveredElevation,
double? focusedElevation,
double? pressedElevation,
}) {
return MaterialStateProperty.resolveWith(
return WidgetStateProperty.resolveWith(
(states) {
if (states.contains(MaterialState.disabled)) {
return disabledElevation ??
elevation.resolve({MaterialState.disabled});
if (states.contains(WidgetState.disabled)) {
return disabledElevation ?? elevation.resolve({WidgetState.disabled});
}
if (states.contains(MaterialState.hovered)) {
return hoveredElevation ?? elevation.resolve({MaterialState.hovered});
if (states.contains(WidgetState.hovered)) {
return hoveredElevation ?? elevation.resolve({WidgetState.hovered});
}
if (states.contains(MaterialState.focused)) {
return focusedElevation ?? elevation.resolve({MaterialState.focused});
if (states.contains(WidgetState.focused)) {
return focusedElevation ?? elevation.resolve({WidgetState.focused});
}
if (states.contains(MaterialState.pressed)) {
return pressedElevation ?? elevation.resolve({MaterialState.pressed});
if (states.contains(WidgetState.pressed)) {
return pressedElevation ?? elevation.resolve({WidgetState.pressed});
}

return defaultElevation ?? elevation.resolve({});
Expand Down
Loading

0 comments on commit cea3e6f

Please sign in to comment.