Skip to content

Commit

Permalink
fix: [MDS-593] Upgrade Flutter to 3.10.5 (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kypsis committed Jul 10, 2023
1 parent 800f3a9 commit a469868
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyze_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/s3_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
1 change: 0 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class _HomePageState extends State<HomePage> {
: MaterialApp(
theme: ThemeData.light().copyWith(extensions: <ThemeExtension<dynamic>>[MoonTheme.light]),
darkTheme: ThemeData.dark().copyWith(extensions: <ThemeExtension<dynamic>>[MoonTheme.dark]),
useInheritedMediaQuery: true,
home: Scaffold(
body: Center(
child: Column(
Expand Down
4 changes: 2 additions & 2 deletions example/lib/src/storybook/storybook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand All @@ -57,7 +58,6 @@ class StorybookPage extends StatelessWidget {
title: "Moon Design for Flutter",
theme: ThemeData.light().copyWith(extensions: <ThemeExtension<dynamic>>[MoonTheme.light]),
darkTheme: ThemeData.dark().copyWith(extensions: <ThemeExtension<dynamic>>[MoonTheme.dark]),
useInheritedMediaQuery: true,
home: Directionality(
textDirection: Directionality.of(context),
child: Focus(
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions lib/src/utils/shape_decoration_premul.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -109,7 +108,6 @@ class ShapeDecorationWithPremultipliedAlpha extends Decoration {
} else {
shape = source.border ?? const Border();
}
break;
}

return ShapeDecorationWithPremultipliedAlpha(
Expand Down
2 changes: 0 additions & 2 deletions lib/src/utils/squircle/squircle_border.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ class MoonSquircleBorder extends OutlinedBorder {
outerPath,
side.toPaint(),
);

break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/avatar/avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions lib/src/widgets/carousel/carousel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion lib/src/widgets/common/icons/moon_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ class MoonIcon extends StatelessWidget {
transformHitTests: false,
child: iconWidget,
);
break;
case TextDirection.ltr:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 0 additions & 8 deletions lib/src/widgets/popover/popover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -392,32 +392,24 @@ class MoonPopoverState extends State<MoonPopover> 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;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/src/widgets/switch/switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,9 @@ class _MoonSwitchState extends State<MoonSwitch> 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;
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions lib/src/widgets/text_input/input_decorator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -1430,15 +1426,13 @@ 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);
}
if (counter != null) {
baselineLayout(counter!, right - counter!.size.width);
}
break;
}
}

Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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)!;
Expand Down
10 changes: 1 addition & 9 deletions lib/src/widgets/text_input/text_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ class _MoonTextInputState extends State<MoonTextInput>
if (cause == SelectionChangedCause.longPress || cause == SelectionChangedCause.drag) {
_editableText?.bringIntoView(selection.extent);
}
break;
}

switch (Theme.of(context).platform) {
Expand All @@ -938,7 +937,6 @@ class _MoonTextInputState extends State<MoonTextInput>
if (cause == SelectionChangedCause.drag) {
_editableText?.hideToolbar();
}
break;
}
}

Expand Down Expand Up @@ -1235,7 +1233,6 @@ class _MoonTextInputState extends State<MoonTextInput>
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);
Expand All @@ -1253,7 +1250,6 @@ class _MoonTextInputState extends State<MoonTextInput>
_effectiveFocusNode.requestFocus();
}
};
break;

case TargetPlatform.android:
case TargetPlatform.fuchsia:
Expand All @@ -1263,7 +1259,6 @@ class _MoonTextInputState extends State<MoonTextInput>
cursorOpacityAnimates = false;
cursorColor = widget.cursorColor ?? effectiveTextColor;
selectionColor = selectionStyle.selectionColor ?? theme.colorScheme.primary.withOpacity(0.40);
break;

case TargetPlatform.linux:
forcePressEnabled = false;
Expand All @@ -1272,7 +1267,6 @@ class _MoonTextInputState extends State<MoonTextInput>
cursorOpacityAnimates = false;
cursorColor = widget.cursorColor ?? effectiveTextColor;
selectionColor = selectionStyle.selectionColor ?? theme.colorScheme.primary.withOpacity(0.40);
break;

case TargetPlatform.windows:
forcePressEnabled = false;
Expand All @@ -1287,7 +1281,6 @@ class _MoonTextInputState extends State<MoonTextInput>
_effectiveFocusNode.requestFocus();
}
};
break;
}

final MouseCursor effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor>(
Expand Down Expand Up @@ -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();
Expand All @@ -1560,7 +1553,6 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
case TargetPlatform.linux:
case TargetPlatform.windows:
Feedback.forLongPress(_state.context);
break;
}
}
}
Expand Down
Loading

0 comments on commit a469868

Please sign in to comment.