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

Fix analysis issues with Flutter v3.22 #354

Merged
merged 6 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/fleather.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.19.0"
flutter-version: "3.22.0"
cache: true
# Manually Update this `key`
cache-key: "20230512"
Expand Down
5 changes: 4 additions & 1 deletion packages/fleather/lib/src/rendering/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,10 @@ class RenderEditor extends RenderEditableContainerBox
final caretOffset = child.getOffsetForCaret(localPosition);
final testPosition = TextPosition(offset: sibling.node.length - 1);
final testOffset = sibling.getOffsetForCaret(testPosition);
final finalOffset = Offset(caretOffset.dx, testOffset.dy);
// The addition of 1 point to testOffset.dy is added because somehow
// in Flutter 3.22 the TextPainter is yielding wrong text position
// for the offset (1 line above the correct line).
final finalOffset = Offset(caretOffset.dx, testOffset.dy + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really strange, no explanation for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find any. I even took a quick look at the commits in framework and engine.

final siblingPosition = sibling.getPositionForOffset(finalOffset);
newPosition = TextPosition(
offset: sibling.node.documentOffset + siblingPosition.offset);
Expand Down
119 changes: 59 additions & 60 deletions packages/fleather/lib/src/widgets/checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
///
/// {@tool dartpad}
/// This example shows how you can override the default theme of
/// of a [FleatherCheckbox] with a [MaterialStateProperty].
/// of a [FleatherCheckbox] with a [WidgetStateProperty].
/// In this example, the checkbox's color will be `Colors.blue` when the [FleatherCheckbox]
/// is being pressed, hovered, or focused. Otherwise, the checkbox's color will
/// be `Colors.red`.
Expand Down Expand Up @@ -124,10 +124,10 @@
bool? get value => widget.value;

BorderSide? _resolveSide(BorderSide? side) {
if (side is MaterialStateBorderSide) {
return MaterialStateProperty.resolveAs<BorderSide?>(side, states);
if (side is WidgetStateBorderSide) {
return WidgetStateProperty.resolveAs<BorderSide?>(side, states);

Check warning on line 128 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L128

Added line #L128 was not covered by tests
}
if (!states.contains(MaterialState.selected)) {
if (!states.contains(WidgetState.selected)) {
return side;
}
return null;
Expand All @@ -141,18 +141,17 @@
? _CheckboxDefaultsM3(context)
: _CheckboxDefaultsM2(context);

final MaterialStateProperty<MouseCursor> effectiveMouseCursor =
MaterialStateProperty.resolveWith<MouseCursor>(
(Set<MaterialState> states) {
final WidgetStateProperty<MouseCursor> effectiveMouseCursor =
WidgetStateProperty.resolveWith<MouseCursor>((Set<WidgetState> states) {
return checkboxTheme.mouseCursor?.resolve(states) ??
MaterialStateMouseCursor.clickable.resolve(states);
WidgetStateMouseCursor.clickable.resolve(states);
});

// Colors need to be resolved in selected and non selected states separately
// so that they can be lerped between.
final Set<MaterialState> activeStates = states..add(MaterialState.selected);
final Set<MaterialState> inactiveStates = states
..remove(MaterialState.selected);
final Set<WidgetState> activeStates = states..add(WidgetState.selected);
final Set<WidgetState> inactiveStates = states
..remove(WidgetState.selected);
final Color? activeColor = checkboxTheme.fillColor?.resolve(activeStates);
final Color effectiveActiveColor =
activeColor ?? defaults.fillColor!.resolve(activeStates)!;
Expand All @@ -161,40 +160,40 @@
final Color effectiveInactiveColor =
inactiveColor ?? defaults.fillColor!.resolve(inactiveStates)!;

final Set<MaterialState> focusedStates = states..add(MaterialState.focused);
final Set<WidgetState> focusedStates = states..add(WidgetState.focused);
Color effectiveFocusOverlayColor =
checkboxTheme.overlayColor?.resolve(focusedStates) ??
defaults.overlayColor!.resolve(focusedStates)!;

final Set<MaterialState> hoveredStates = states..add(MaterialState.hovered);
final Set<WidgetState> hoveredStates = states..add(WidgetState.hovered);
Color effectiveHoverOverlayColor =
checkboxTheme.overlayColor?.resolve(hoveredStates) ??
defaults.overlayColor!.resolve(hoveredStates)!;

final Set<MaterialState> activePressedStates = activeStates
..add(MaterialState.pressed);
final Set<WidgetState> activePressedStates = activeStates
..add(WidgetState.pressed);
final Color effectiveActivePressedOverlayColor =
checkboxTheme.overlayColor?.resolve(activePressedStates) ??
activeColor?.withAlpha(kRadialReactionAlpha) ??
defaults.overlayColor!.resolve(activePressedStates)!;

final Set<MaterialState> inactivePressedStates = inactiveStates
..add(MaterialState.pressed);
final Set<WidgetState> inactivePressedStates = inactiveStates
..add(WidgetState.pressed);
final Color effectiveInactivePressedOverlayColor =
checkboxTheme.overlayColor?.resolve(inactivePressedStates) ??
inactiveColor?.withAlpha(kRadialReactionAlpha) ??
defaults.overlayColor!.resolve(inactivePressedStates)!;

if (downPosition != null) {
effectiveHoverOverlayColor = states.contains(MaterialState.selected)
effectiveHoverOverlayColor = states.contains(WidgetState.selected)

Check warning on line 188 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L188

Added line #L188 was not covered by tests
? effectiveActivePressedOverlayColor
: effectiveInactivePressedOverlayColor;
effectiveFocusOverlayColor = states.contains(MaterialState.selected)
effectiveFocusOverlayColor = states.contains(WidgetState.selected)

Check warning on line 191 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L191

Added line #L191 was not covered by tests
? effectiveActivePressedOverlayColor
: effectiveInactivePressedOverlayColor;
}

final Set<MaterialState> checkStates = states;
final Set<WidgetState> checkStates = states;
final Color effectiveCheckColor =
checkboxTheme.checkColor?.resolve(checkStates) ??
defaults.checkColor!.resolve(checkStates)!;
Expand All @@ -218,8 +217,8 @@
..focusColor = effectiveFocusOverlayColor
..splashRadius = effectiveSplashRadius
..downPosition = downPosition
..isFocused = states.contains(MaterialState.focused)
..isHovered = states.contains(MaterialState.hovered)
..isFocused = states.contains(WidgetState.focused)
..isHovered = states.contains(WidgetState.hovered)
..activeColor = effectiveActiveColor
..inactiveColor = effectiveInactiveColor
..checkColor = effectiveCheckColor
Expand Down Expand Up @@ -435,33 +434,33 @@
final ColorScheme _colors;

@override
MaterialStateProperty<Color> get fillColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
WidgetStateProperty<Color> get fillColor {
return WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {

Check warning on line 439 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L438-L439

Added lines #L438 - L439 were not covered by tests
return _theme.disabledColor;
}
if (states.contains(MaterialState.selected)) {
if (states.contains(WidgetState.selected)) {

Check warning on line 442 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L442

Added line #L442 was not covered by tests
return _colors.secondary;
}
return _theme.unselectedWidgetColor;
});
}

@override
MaterialStateProperty<Color> get checkColor {
return MaterialStateProperty.all<Color>(const Color(0xFFFFFFFF));
WidgetStateProperty<Color> get checkColor {
return WidgetStateProperty.all<Color>(const Color(0xFFFFFFFF));

Check warning on line 451 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L451

Added line #L451 was not covered by tests
}

@override
MaterialStateProperty<Color?> get overlayColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
WidgetStateProperty<Color?> get overlayColor {
return WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.pressed)) {

Check warning on line 457 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L456-L457

Added lines #L456 - L457 were not covered by tests
return fillColor.resolve(states).withAlpha(kRadialReactionAlpha);
}
if (states.contains(MaterialState.hovered)) {
if (states.contains(WidgetState.hovered)) {

Check warning on line 460 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L460

Added line #L460 was not covered by tests
return _theme.hoverColor;
}
if (states.contains(MaterialState.focused)) {
if (states.contains(WidgetState.focused)) {

Check warning on line 463 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L463

Added line #L463 was not covered by tests
return _theme.focusColor;
}
return Colors.transparent;
Expand Down Expand Up @@ -497,42 +496,42 @@
final ColorScheme _colors;

@override
MaterialStateProperty<Color> get fillColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
WidgetStateProperty<Color> get fillColor {
return WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return _colors.onSurface.withOpacity(0.38);
}
if (states.contains(MaterialState.error)) {
if (states.contains(WidgetState.error)) {
return _colors.error;
}
if (states.contains(MaterialState.selected)) {
if (states.contains(WidgetState.selected)) {
return _colors.primary;
}
if (states.contains(MaterialState.pressed)) {
if (states.contains(WidgetState.pressed)) {
return _colors.onSurface;
}
if (states.contains(MaterialState.hovered)) {
if (states.contains(WidgetState.hovered)) {
return _colors.onSurface;
}
if (states.contains(MaterialState.focused)) {
if (states.contains(WidgetState.focused)) {
return _colors.onSurface;
}
return _colors.onSurfaceVariant;
});
}

@override
MaterialStateProperty<Color> get checkColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
if (states.contains(MaterialState.selected)) {
WidgetStateProperty<Color> get checkColor {
return WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
if (states.contains(WidgetState.selected)) {

Check warning on line 527 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L527

Added line #L527 was not covered by tests
return _colors.surface;
}
return Colors
.transparent; // No icons available when the checkbox is unselected.
}
if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.error)) {
if (states.contains(WidgetState.selected)) {
if (states.contains(WidgetState.error)) {
return _colors.onError;
}
return _colors.onPrimary;
Expand All @@ -543,38 +542,38 @@
}

@override
MaterialStateProperty<Color> get overlayColor {
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.pressed)) {
WidgetStateProperty<Color> get overlayColor {
return WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.error)) {
if (states.contains(WidgetState.pressed)) {

Check warning on line 548 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L548

Added line #L548 was not covered by tests
return _colors.error.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) {
if (states.contains(WidgetState.hovered)) {

Check warning on line 551 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L551

Added line #L551 was not covered by tests
return _colors.error.withOpacity(0.08);
}
if (states.contains(MaterialState.focused)) {
if (states.contains(WidgetState.focused)) {

Check warning on line 554 in packages/fleather/lib/src/widgets/checkbox.dart

View check run for this annotation

Codecov / codecov/patch

packages/fleather/lib/src/widgets/checkbox.dart#L554

Added line #L554 was not covered by tests
return _colors.error.withOpacity(0.12);
}
}
if (states.contains(MaterialState.selected)) {
if (states.contains(MaterialState.pressed)) {
if (states.contains(WidgetState.selected)) {
if (states.contains(WidgetState.pressed)) {
return _colors.onSurface.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) {
if (states.contains(WidgetState.hovered)) {
return _colors.primary.withOpacity(0.08);
}
if (states.contains(MaterialState.focused)) {
if (states.contains(WidgetState.focused)) {
return _colors.primary.withOpacity(0.12);
}
return Colors.transparent;
}
if (states.contains(MaterialState.pressed)) {
if (states.contains(WidgetState.pressed)) {
return _colors.primary.withOpacity(0.12);
}
if (states.contains(MaterialState.hovered)) {
if (states.contains(WidgetState.hovered)) {
return _colors.onSurface.withOpacity(0.08);
}
if (states.contains(MaterialState.focused)) {
if (states.contains(WidgetState.focused)) {
return _colors.onSurface.withOpacity(0.12);
}
return Colors.transparent;
Expand Down
4 changes: 2 additions & 2 deletions packages/fleather/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ environment:
dependencies:
flutter:
sdk: flutter
collection: ^1.16.0
collection: ^1.18.0
parchment_delta: ^1.0.0
parchment: ^1.14.0
intl: ">=0.18.1 <=0.19.0"
intl: ^0.19.0

dependency_overrides:
parchment:
Expand Down
Loading
Loading