From a4698685f9bac6f40f604cbb4a0132c9c29ab8b3 Mon Sep 17 00:00:00 2001 From: Harry Sild <46851868+Kypsis@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:59:48 +0300 Subject: [PATCH] fix: [MDS-593] Upgrade Flutter to 3.10.5 (#205) --- .github/workflows/analyze_and_test.yaml | 2 +- .github/workflows/release.yml | 1 + .github/workflows/s3_deploy.yml | 2 +- example/android/build.gradle | 2 +- example/lib/main.dart | 1 - example/lib/src/storybook/storybook.dart | 4 ++-- example/pubspec.yaml | 4 ++-- lib/src/utils/shape_decoration_premul.dart | 2 -- lib/src/utils/squircle/squircle_border.dart | 2 -- lib/src/widgets/avatar/avatar.dart | 2 +- lib/src/widgets/carousel/carousel.dart | 16 ++++++++-------- lib/src/widgets/common/icons/moon_icon.dart | 1 - .../linear_progress_indicator_painter.dart | 2 -- lib/src/widgets/popover/popover.dart | 8 -------- lib/src/widgets/switch/switch.dart | 2 -- lib/src/widgets/text_input/input_decorator.dart | 10 ---------- lib/src/widgets/text_input/text_input.dart | 10 +--------- lib/src/widgets/tooltip/tooltip.dart | 8 -------- pubspec.yaml | 4 ++-- 19 files changed, 20 insertions(+), 63 deletions(-) diff --git a/.github/workflows/analyze_and_test.yaml b/.github/workflows/analyze_and_test.yaml index 8a74e049..0a7f8ecd 100644 --- a/.github/workflows/analyze_and_test.yaml +++ b/.github/workflows/analyze_and_test.yaml @@ -12,7 +12,7 @@ jobs: - uses: subosito/flutter-action@v2 with: - flutter-version: '3.7.12' + flutter-version: '3.10.5' channel: stable - name: Install Dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6525695e..0ec6fd67 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,7 @@ jobs: - uses: google-github-actions/release-please-action@v3 id: release with: + release-type: "dart" command: manifest outputs: release_created: ${{ steps.release.outputs.release_created }} diff --git a/.github/workflows/s3_deploy.yml b/.github/workflows/s3_deploy.yml index a06c0ae3..38f46396 100644 --- a/.github/workflows/s3_deploy.yml +++ b/.github/workflows/s3_deploy.yml @@ -17,7 +17,7 @@ jobs: - uses: subosito/flutter-action@v2 with: - flutter-version: '3.7.12' + flutter-version: '3.10.5' channel: stable - name: Install Dependencies diff --git a/example/android/build.gradle b/example/android/build.gradle index 83ae2200..3cdaac95 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/lib/main.dart b/example/lib/main.dart index d5e9da39..4f8683dc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -50,7 +50,6 @@ class _HomePageState extends State { : MaterialApp( theme: ThemeData.light().copyWith(extensions: >[MoonTheme.light]), darkTheme: ThemeData.dark().copyWith(extensions: >[MoonTheme.dark]), - useInheritedMediaQuery: true, home: Scaffold( body: Center( child: Column( diff --git a/example/lib/src/storybook/storybook.dart b/example/lib/src/storybook/storybook.dart index 97ea3d6e..8f4bc793 100644 --- a/example/lib/src/storybook/storybook.dart +++ b/example/lib/src/storybook/storybook.dart @@ -25,12 +25,13 @@ import 'package:example/src/storybook/stories/text_area.dart'; import 'package:example/src/storybook/stories/text_input.dart'; import 'package:example/src/storybook/stories/toast.dart'; import 'package:example/src/storybook/stories/tooltip.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:moon_design/moon_design.dart'; import 'package:storybook_flutter/storybook_flutter.dart'; class StorybookPage extends StatelessWidget { - static bool isLargeScreen = MediaQueryData.fromWindow(WidgetsBinding.instance.window).size.width > 1000; + static bool isLargeScreen = MediaQueryData.fromView(PlatformDispatcher.instance.implicitView!).size.width > 1000; const StorybookPage({super.key}); @@ -57,7 +58,6 @@ class StorybookPage extends StatelessWidget { title: "Moon Design for Flutter", theme: ThemeData.light().copyWith(extensions: >[MoonTheme.light]), darkTheme: ThemeData.dark().copyWith(extensions: >[MoonTheme.dark]), - useInheritedMediaQuery: true, home: Directionality( textDirection: Directionality.of(context), child: Focus( diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b5266dc9..c2258b38 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,7 +3,7 @@ description: Showcase Moon Design. publish_to: none version: 0.25.0 environment: - sdk: '>=2.18.6 <3.0.0' + sdk: '>=3.0.5 <4.0.0' dependencies: cupertino_icons: ^1.0.2 flutter: @@ -17,7 +17,7 @@ dev_dependencies: flutter_lints: ^2.0.0 flutter_test: sdk: flutter - lint: ^2.0.1 + lint: ^2.1.2 storybook_flutter: git: url: https://github.com/coingaming/storybook_flutter.git diff --git a/lib/src/utils/shape_decoration_premul.dart b/lib/src/utils/shape_decoration_premul.dart index 4dc13bff..e4a50365 100644 --- a/lib/src/utils/shape_decoration_premul.dart +++ b/lib/src/utils/shape_decoration_premul.dart @@ -98,7 +98,6 @@ class ShapeDecorationWithPremultipliedAlpha extends Decoration { } else { shape = const CircleBorder(); } - break; case BoxShape.rectangle: if (source.borderRadius != null) { assert(source.border == null || source.border!.isUniform); @@ -109,7 +108,6 @@ class ShapeDecorationWithPremultipliedAlpha extends Decoration { } else { shape = source.border ?? const Border(); } - break; } return ShapeDecorationWithPremultipliedAlpha( diff --git a/lib/src/utils/squircle/squircle_border.dart b/lib/src/utils/squircle/squircle_border.dart index bad4015f..f81742a1 100644 --- a/lib/src/utils/squircle/squircle_border.dart +++ b/lib/src/utils/squircle/squircle_border.dart @@ -191,8 +191,6 @@ class MoonSquircleBorder extends OutlinedBorder { outerPath, side.toPaint(), ); - - break; } } diff --git a/lib/src/widgets/avatar/avatar.dart b/lib/src/widgets/avatar/avatar.dart index 9c99ab4f..0ed9d102 100644 --- a/lib/src/widgets/avatar/avatar.dart +++ b/lib/src/widgets/avatar/avatar.dart @@ -177,7 +177,7 @@ class MoonAvatar extends StatelessWidget { child: ClipPath( // TODO: Since clipper does not work properly on mobile web/PWA, we are disabling it. Remove this check // when it has been fixed from Flutter side. - clipper: kIsWeb && MediaQueryData.fromWindow(WidgetsBinding.instance.window).size.width < 500 + clipper: kIsWeb && MediaQueryData.fromView(View.of(context)).size.width < 500 ? null : AvatarClipper( showBadge: showBadge, diff --git a/lib/src/widgets/carousel/carousel.dart b/lib/src/widgets/carousel/carousel.dart index e301e388..4d4aa37e 100644 --- a/lib/src/widgets/carousel/carousel.dart +++ b/lib/src/widgets/carousel/carousel.dart @@ -484,19 +484,19 @@ class MoonCarouselExtentMetrics extends FixedScrollMetrics { /// This is an immutable snapshot of the current values of scroll positions. This can directly be accessed by /// [ScrollNotification] to get currently selected real item index at any time. MoonCarouselExtentMetrics({ - required super.axisDirection, - required super.maxScrollExtent, required super.minScrollExtent, + required super.maxScrollExtent, required super.pixels, required super.viewportDimension, - //TODO: uncomment when 3.10: required double devicePixelRatio, + required super.axisDirection, + required super.devicePixelRatio, required this.itemIndex, }); @override MoonCarouselExtentMetrics copyWith({ AxisDirection? axisDirection, - //TODO: uncomment when 3.10: double? devicePixelRatio, + double? devicePixelRatio, double? minScrollExtent, double? maxScrollExtent, double? pixels, @@ -505,7 +505,7 @@ class MoonCarouselExtentMetrics extends FixedScrollMetrics { }) { return MoonCarouselExtentMetrics( axisDirection: axisDirection ?? this.axisDirection, - //TODO: uncomment when 3.10: devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, + devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, minScrollExtent: minScrollExtent ?? (hasContentDimensions ? this.minScrollExtent : 0.0), maxScrollExtent: maxScrollExtent ?? this.maxScrollExtent, pixels: pixels ?? this.pixels, @@ -589,7 +589,7 @@ class _MoonCarouselScrollPosition extends ScrollPositionWithSingleContext implem @override MoonCarouselExtentMetrics copyWith({ AxisDirection? axisDirection, - //TODO: uncomment when 3.10: double? devicePixelRatio, + double? devicePixelRatio, double? minScrollExtent, double? maxScrollExtent, double? pixels, @@ -598,7 +598,7 @@ class _MoonCarouselScrollPosition extends ScrollPositionWithSingleContext implem }) { return MoonCarouselExtentMetrics( axisDirection: axisDirection ?? this.axisDirection, - //TODO: uncomment when 3.10: devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, + devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, minScrollExtent: minScrollExtent ?? (hasContentDimensions ? this.minScrollExtent : 0.0), maxScrollExtent: maxScrollExtent ?? this.maxScrollExtent, pixels: pixels ?? this.pixels, @@ -708,7 +708,7 @@ class MoonCarouselScrollPhysics extends ScrollPhysics { // Scenario 3: // If there's no velocity and we're already at where we intend to land, do nothing. - //TODO: uncomment when 3.10: final tolerance = toleranceFor(metrics); + final tolerance = toleranceFor(metrics); if (velocity.abs() < tolerance.velocity && (settlingPixels - metrics.pixels).abs() < tolerance.distance) { return null; } diff --git a/lib/src/widgets/common/icons/moon_icon.dart b/lib/src/widgets/common/icons/moon_icon.dart index e4dc96b2..2625235d 100644 --- a/lib/src/widgets/common/icons/moon_icon.dart +++ b/lib/src/widgets/common/icons/moon_icon.dart @@ -234,7 +234,6 @@ class MoonIcon extends StatelessWidget { transformHitTests: false, child: iconWidget, ); - break; case TextDirection.ltr: break; } diff --git a/lib/src/widgets/common/progress_indicators/painters/linear_progress_indicator_painter.dart b/lib/src/widgets/common/progress_indicators/painters/linear_progress_indicator_painter.dart index f7c8fc15..2734d561 100644 --- a/lib/src/widgets/common/progress_indicators/painters/linear_progress_indicator_painter.dart +++ b/lib/src/widgets/common/progress_indicators/painters/linear_progress_indicator_painter.dart @@ -75,10 +75,8 @@ class MoonLinearProgressIndicatorPainter extends CustomPainter { switch (textDirection) { case TextDirection.rtl: left = size.width - width - x; - break; case TextDirection.ltr: left = x; - break; } final progressRect = RRect.fromRectAndCorners( diff --git a/lib/src/widgets/popover/popover.dart b/lib/src/widgets/popover/popover.dart index a1bdc7f9..d83e8ff0 100644 --- a/lib/src/widgets/popover/popover.dart +++ b/lib/src/widgets/popover/popover.dart @@ -392,32 +392,24 @@ class MoonPopoverState extends State with RouteAware, SingleTickerP switch (popoverPosition) { case MoonPopoverPosition.left: popoverPosition = MoonPopoverPosition.right; - break; case MoonPopoverPosition.right: popoverPosition = MoonPopoverPosition.left; - break; case MoonPopoverPosition.topLeft: popoverPosition = MoonPopoverPosition.topRight; - break; case MoonPopoverPosition.topRight: popoverPosition = MoonPopoverPosition.topLeft; - break; case MoonPopoverPosition.bottomLeft: popoverPosition = MoonPopoverPosition.bottomRight; - break; case MoonPopoverPosition.bottomRight: popoverPosition = MoonPopoverPosition.bottomLeft; - break; case MoonPopoverPosition.vertical: popoverPosition = popoverTargetGlobalCenter.dy < overlayRenderBox.size.center(Offset.zero).dy ? MoonPopoverPosition.bottom : MoonPopoverPosition.top; - break; case MoonPopoverPosition.horizontal: popoverPosition = popoverTargetGlobalCenter.dx < overlayRenderBox.size.center(Offset.zero).dx ? MoonPopoverPosition.right : MoonPopoverPosition.left; - break; default: break; } diff --git a/lib/src/widgets/switch/switch.dart b/lib/src/widgets/switch/switch.dart index 9df15d13..5904655f 100644 --- a/lib/src/widgets/switch/switch.dart +++ b/lib/src/widgets/switch/switch.dart @@ -222,11 +222,9 @@ class _MoonSwitchState extends State with SingleTickerProviderStateM case TextDirection.rtl: _animationController!.value += -details.primaryDelta! / (switchWidth - (thumbSizeValue + padding.right + padding.left)); - break; case TextDirection.ltr: _animationController!.value += details.primaryDelta! / (switchWidth - (thumbSizeValue + padding.right + padding.left)); - break; } } } diff --git a/lib/src/widgets/text_input/input_decorator.dart b/lib/src/widgets/text_input/input_decorator.dart index f7527255..fd38eeae 100644 --- a/lib/src/widgets/text_input/input_decorator.dart +++ b/lib/src/widgets/text_input/input_decorator.dart @@ -1310,10 +1310,8 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin switch (textDirection) { case TextDirection.rtl: x = 0.0; - break; case TextDirection.ltr: x = _boxSize(icon).width; - break; } _boxParentData(container).offset = Offset(x, 0.0); } @@ -1341,10 +1339,8 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin switch (textDirection) { case TextDirection.rtl: x = overallWidth - icon!.size.width; - break; case TextDirection.ltr: x = 0.0; - break; } centerLayout(icon!, x); } @@ -1430,7 +1426,6 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin if (counter != null) { baselineLayout(counter!, left); } - break; case TextDirection.ltr: if (helperError != null) { baselineLayout(helperError!, left + _boxSize(icon).width); @@ -1438,7 +1433,6 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin if (counter != null) { baselineLayout(counter!, right - counter!.size.width); } - break; } } @@ -1461,7 +1455,6 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin floatAlign, ); - break; case TextDirection.ltr: // The value of _InputBorderGap.start is relative to the origin of the // _BorderContainer which is inset by the icon's width. Although, when @@ -1475,7 +1468,6 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin _boxSize(container).width / 2.0 - floatWidth / 2.0, floatAlign, ); - break; } decoration.borderGap.extent = label!.size.width * _kFinalLabelScale; } else { @@ -1531,14 +1523,12 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin if (prefixIcon != null && !decoration.alignLabelWithHint && isOutlineBorder) { floatStartX += material3 ? _boxSize(prefixIcon).width - contentPadding.left : 0.0; } - break; case TextDirection.ltr: // origin on the left startX = labelOffset.dx; floatStartX = startX; if (prefixIcon != null && !decoration.alignLabelWithHint && isOutlineBorder) { floatStartX += material3 ? -_boxSize(prefixIcon).width + contentPadding.left : 0.0; } - break; } final double floatEndX = lerpDouble(floatStartX, centeredFloatX, floatAlign)!; final double dx = lerpDouble(startX, floatEndX, t)!; diff --git a/lib/src/widgets/text_input/text_input.dart b/lib/src/widgets/text_input/text_input.dart index 4b45829d..b4f877e6 100644 --- a/lib/src/widgets/text_input/text_input.dart +++ b/lib/src/widgets/text_input/text_input.dart @@ -924,7 +924,6 @@ class _MoonTextInputState extends State if (cause == SelectionChangedCause.longPress || cause == SelectionChangedCause.drag) { _editableText?.bringIntoView(selection.extent); } - break; } switch (Theme.of(context).platform) { @@ -938,7 +937,6 @@ class _MoonTextInputState extends State if (cause == SelectionChangedCause.drag) { _editableText?.hideToolbar(); } - break; } } @@ -1235,7 +1233,6 @@ class _MoonTextInputState extends State cursorRadius ??= const Radius.circular(2.0); cursorOffset = Offset(iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0); autocorrectionTextRectColor = selectionColor; - break; case TargetPlatform.macOS: final CupertinoThemeData cupertinoTheme = CupertinoTheme.of(context); @@ -1253,7 +1250,6 @@ class _MoonTextInputState extends State _effectiveFocusNode.requestFocus(); } }; - break; case TargetPlatform.android: case TargetPlatform.fuchsia: @@ -1263,7 +1259,6 @@ class _MoonTextInputState extends State cursorOpacityAnimates = false; cursorColor = widget.cursorColor ?? effectiveTextColor; selectionColor = selectionStyle.selectionColor ?? theme.colorScheme.primary.withOpacity(0.40); - break; case TargetPlatform.linux: forcePressEnabled = false; @@ -1272,7 +1267,6 @@ class _MoonTextInputState extends State cursorOpacityAnimates = false; cursorColor = widget.cursorColor ?? effectiveTextColor; selectionColor = selectionStyle.selectionColor ?? theme.colorScheme.primary.withOpacity(0.40); - break; case TargetPlatform.windows: forcePressEnabled = false; @@ -1287,7 +1281,6 @@ class _MoonTextInputState extends State _effectiveFocusNode.requestFocus(); } }; - break; } final MouseCursor effectiveMouseCursor = MaterialStateProperty.resolveAs( @@ -1541,7 +1534,7 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete } @override - void onSingleTapUp(TapUpDetails details) { + void onSingleTapUp(TapDragUpDetails details) { super.onSingleTapUp(details); _state._requestKeyboard(); _state.widget.onTap?.call(); @@ -1560,7 +1553,6 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete case TargetPlatform.linux: case TargetPlatform.windows: Feedback.forLongPress(_state.context); - break; } } } diff --git a/lib/src/widgets/tooltip/tooltip.dart b/lib/src/widgets/tooltip/tooltip.dart index 6e7efb79..c7d972c8 100644 --- a/lib/src/widgets/tooltip/tooltip.dart +++ b/lib/src/widgets/tooltip/tooltip.dart @@ -437,32 +437,24 @@ class _MoonTooltipState extends State with RouteAware, SingleTicker switch (tooltipPosition) { case MoonTooltipPosition.left: tooltipPosition = MoonTooltipPosition.right; - break; case MoonTooltipPosition.right: tooltipPosition = MoonTooltipPosition.left; - break; case MoonTooltipPosition.topLeft: tooltipPosition = MoonTooltipPosition.topRight; - break; case MoonTooltipPosition.topRight: tooltipPosition = MoonTooltipPosition.topLeft; - break; case MoonTooltipPosition.bottomLeft: tooltipPosition = MoonTooltipPosition.bottomRight; - break; case MoonTooltipPosition.bottomRight: tooltipPosition = MoonTooltipPosition.bottomLeft; - break; case MoonTooltipPosition.vertical: tooltipPosition = tooltipTargetGlobalCenter.dy < overlayRenderBox.size.center(Offset.zero).dy ? MoonTooltipPosition.bottom : MoonTooltipPosition.top; - break; case MoonTooltipPosition.horizontal: tooltipPosition = tooltipTargetGlobalCenter.dx < overlayRenderBox.size.center(Offset.zero).dx ? MoonTooltipPosition.right : MoonTooltipPosition.left; - break; default: break; } diff --git a/pubspec.yaml b/pubspec.yaml index 2a98d778..015c8220 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.25.0 homepage: https://flutter.moon.io/ environment: - sdk: '>=2.18.6 <3.0.0' + sdk: '>=3.0.5 <4.0.0' flutter: ">=1.17.0" dependencies: @@ -14,7 +14,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - lint: ^2.0.1 + lint: ^2.1.2 flutter: uses-material-design: true