diff --git a/.github/workflows/fleather.yml b/.github/workflows/fleather.yml index 986ed0ee..f22634c3 100644 --- a/.github/workflows/fleather.yml +++ b/.github/workflows/fleather.yml @@ -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" diff --git a/packages/fleather/lib/src/rendering/editor.dart b/packages/fleather/lib/src/rendering/editor.dart index 120b3401..977630a3 100644 --- a/packages/fleather/lib/src/rendering/editor.dart +++ b/packages/fleather/lib/src/rendering/editor.dart @@ -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); final siblingPosition = sibling.getPositionForOffset(finalOffset); newPosition = TextPosition( offset: sibling.node.documentOffset + siblingPosition.offset); diff --git a/packages/fleather/lib/src/widgets/checkbox.dart b/packages/fleather/lib/src/widgets/checkbox.dart index b0d93d6e..b1b5c3fd 100644 --- a/packages/fleather/lib/src/widgets/checkbox.dart +++ b/packages/fleather/lib/src/widgets/checkbox.dart @@ -16,7 +16,7 @@ import 'package:flutter/material.dart'; /// /// {@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`. @@ -124,10 +124,10 @@ class _FleatherCheckboxState extends State bool? get value => widget.value; BorderSide? _resolveSide(BorderSide? side) { - if (side is MaterialStateBorderSide) { - return MaterialStateProperty.resolveAs(side, states); + if (side is WidgetStateBorderSide) { + return WidgetStateProperty.resolveAs(side, states); } - if (!states.contains(MaterialState.selected)) { + if (!states.contains(WidgetState.selected)) { return side; } return null; @@ -141,18 +141,17 @@ class _FleatherCheckboxState extends State ? _CheckboxDefaultsM3(context) : _CheckboxDefaultsM2(context); - final MaterialStateProperty effectiveMouseCursor = - MaterialStateProperty.resolveWith( - (Set states) { + final WidgetStateProperty effectiveMouseCursor = + WidgetStateProperty.resolveWith((Set 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 activeStates = states..add(MaterialState.selected); - final Set inactiveStates = states - ..remove(MaterialState.selected); + final Set activeStates = states..add(WidgetState.selected); + final Set inactiveStates = states + ..remove(WidgetState.selected); final Color? activeColor = checkboxTheme.fillColor?.resolve(activeStates); final Color effectiveActiveColor = activeColor ?? defaults.fillColor!.resolve(activeStates)!; @@ -161,40 +160,40 @@ class _FleatherCheckboxState extends State final Color effectiveInactiveColor = inactiveColor ?? defaults.fillColor!.resolve(inactiveStates)!; - final Set focusedStates = states..add(MaterialState.focused); + final Set focusedStates = states..add(WidgetState.focused); Color effectiveFocusOverlayColor = checkboxTheme.overlayColor?.resolve(focusedStates) ?? defaults.overlayColor!.resolve(focusedStates)!; - final Set hoveredStates = states..add(MaterialState.hovered); + final Set hoveredStates = states..add(WidgetState.hovered); Color effectiveHoverOverlayColor = checkboxTheme.overlayColor?.resolve(hoveredStates) ?? defaults.overlayColor!.resolve(hoveredStates)!; - final Set activePressedStates = activeStates - ..add(MaterialState.pressed); + final Set activePressedStates = activeStates + ..add(WidgetState.pressed); final Color effectiveActivePressedOverlayColor = checkboxTheme.overlayColor?.resolve(activePressedStates) ?? activeColor?.withAlpha(kRadialReactionAlpha) ?? defaults.overlayColor!.resolve(activePressedStates)!; - final Set inactivePressedStates = inactiveStates - ..add(MaterialState.pressed); + final Set 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) ? effectiveActivePressedOverlayColor : effectiveInactivePressedOverlayColor; - effectiveFocusOverlayColor = states.contains(MaterialState.selected) + effectiveFocusOverlayColor = states.contains(WidgetState.selected) ? effectiveActivePressedOverlayColor : effectiveInactivePressedOverlayColor; } - final Set checkStates = states; + final Set checkStates = states; final Color effectiveCheckColor = checkboxTheme.checkColor?.resolve(checkStates) ?? defaults.checkColor!.resolve(checkStates)!; @@ -218,8 +217,8 @@ class _FleatherCheckboxState extends State ..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 @@ -435,12 +434,12 @@ class _CheckboxDefaultsM2 extends CheckboxThemeData { final ColorScheme _colors; @override - MaterialStateProperty get fillColor { - return MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) { + WidgetStateProperty get fillColor { + return WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.disabled)) { return _theme.disabledColor; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return _colors.secondary; } return _theme.unselectedWidgetColor; @@ -448,20 +447,20 @@ class _CheckboxDefaultsM2 extends CheckboxThemeData { } @override - MaterialStateProperty get checkColor { - return MaterialStateProperty.all(const Color(0xFFFFFFFF)); + WidgetStateProperty get checkColor { + return WidgetStateProperty.all(const Color(0xFFFFFFFF)); } @override - MaterialStateProperty get overlayColor { - return MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty get overlayColor { + return WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.pressed)) { return fillColor.resolve(states).withAlpha(kRadialReactionAlpha); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _theme.hoverColor; } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _theme.focusColor; } return Colors.transparent; @@ -497,24 +496,24 @@ class _CheckboxDefaultsM3 extends CheckboxThemeData { final ColorScheme _colors; @override - MaterialStateProperty get fillColor { - return MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) { + WidgetStateProperty get fillColor { + return WidgetStateProperty.resolveWith((Set 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; @@ -522,17 +521,17 @@ class _CheckboxDefaultsM3 extends CheckboxThemeData { } @override - MaterialStateProperty get checkColor { - return MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty get checkColor { + return WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.disabled)) { + if (states.contains(WidgetState.selected)) { 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; @@ -543,38 +542,38 @@ class _CheckboxDefaultsM3 extends CheckboxThemeData { } @override - MaterialStateProperty get overlayColor { - return MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.error)) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty get overlayColor { + return WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.error)) { + if (states.contains(WidgetState.pressed)) { return _colors.error.withOpacity(0.12); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.error.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { 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; diff --git a/packages/fleather/pubspec.yaml b/packages/fleather/pubspec.yaml index 933c53f1..f9bad4b6 100644 --- a/packages/fleather/pubspec.yaml +++ b/packages/fleather/pubspec.yaml @@ -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: diff --git a/packages/fleather/test/widgets/editor_test.dart b/packages/fleather/test/widgets/editor_test.dart index f99d03db..4f7414e2 100644 --- a/packages/fleather/test/widgets/editor_test.dart +++ b/packages/fleather/test/widgets/editor_test.dart @@ -4,12 +4,10 @@ import 'package:fleather/src/widgets/keyboard_listener.dart'; import 'package:fleather/src/widgets/single_child_scroll_view.dart'; import 'package:fleather/src/widgets/text_selection.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:meta/meta.dart'; import 'package:parchment_delta/parchment_delta.dart'; import '../testing.dart'; @@ -423,7 +421,7 @@ void main() { expect(find.byType(TextSelectionToolbar), findsNothing); }); - testWidgetsWithPlatform( + testWidgets( 'Secondary tap opens toolbar and selects the word on mac/iOS when not focused or tap was different than selection', (tester) async { final document = ParchmentDocument.fromJson([ @@ -454,9 +452,9 @@ void main() { extentOffset: 4, affinity: TextAffinity.upstream)); expect(find.byType(CupertinoTextSelectionToolbar), findsOneWidget); - }, [TargetPlatform.iOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); - testWidgetsWithPlatform( + testWidgets( 'Secondary tap opens toolbar and selection is collapsed on mac/iOS when focused or tap position was the same as selection', (tester) async { final document = ParchmentDocument.fromJson([ @@ -489,9 +487,9 @@ void main() { editor.selection, const TextSelection.collapsed( offset: 0, affinity: TextAffinity.downstream)); - }, [TargetPlatform.macOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.macOS)); - testWidgetsWithPlatform( + testWidgets( 'Secondary tap toggles toolbar on platforms other than mac/iOS', (tester) async { final document = ParchmentDocument.fromJson([ @@ -515,9 +513,9 @@ void main() { buttons: kSecondaryMouseButton); await tester.pump(); expect(find.byType(DesktopTextSelectionToolbar), findsNothing); - }, [TargetPlatform.windows]); + }, variant: TargetPlatformVariant.only(TargetPlatform.windows)); - testWidgetsWithPlatform( + testWidgets( 'Shift tap selects from beginning when unfocused on macOS/iOS', (tester) async { final document = ParchmentDocument.fromJson([ @@ -532,6 +530,7 @@ void main() { await tester.sendKeyDownEvent(LogicalKeyboardKey.shift); await tester.tapAt(tester.getTopRight(find.byType(FleatherEditor)) + const Offset(-1, 1)); + await tester.sendKeyUpEvent(LogicalKeyboardKey.shift); await tester.pump(); expect( editor.selection, @@ -539,9 +538,11 @@ void main() { baseOffset: 0, extentOffset: 4, affinity: TextAffinity.upstream)); - }, [TargetPlatform.macOS, TargetPlatform.iOS]); + }, + variant: const TargetPlatformVariant( + {TargetPlatform.iOS, TargetPlatform.macOS})); - testWidgetsWithPlatform( + testWidgets( 'Shift tap selects from current selection when focused on macOS/iOS', (tester) async { final document = ParchmentDocument.fromJson([ @@ -554,6 +555,7 @@ void main() { await tester.sendKeyDownEvent(LogicalKeyboardKey.shift); await tester.tapAt(tester.getBottomRight(find.byType(FleatherEditor)) - const Offset(1, 1)); + await tester.sendKeyUpEvent(LogicalKeyboardKey.shift); await tester.pump(); expect( editor.selection, @@ -561,9 +563,11 @@ void main() { baseOffset: 1, extentOffset: 4, affinity: TextAffinity.upstream)); - }, [TargetPlatform.macOS, TargetPlatform.iOS]); + }, + variant: const TargetPlatformVariant( + {TargetPlatform.macOS, TargetPlatform.iOS})); - testWidgetsWithPlatform('Mouse drag updates selection', (tester) async { + testWidgets('Mouse drag updates selection', (tester) async { final document = ParchmentDocument.fromJson([ {'insert': 'Test\n'} ]); @@ -589,10 +593,9 @@ void main() { baseOffset: 1, extentOffset: 2, affinity: TextAffinity.upstream)); - }, [TargetPlatform.macOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.macOS)); - testWidgetsWithPlatform('Mouse drag with shift extends selection', - (tester) async { + testWidgets('Mouse drag with shift extends selection', (tester) async { final document = ParchmentDocument.fromJson([ {'insert': 'Test test\n'} ]); @@ -622,10 +625,9 @@ void main() { baseOffset: 1, extentOffset: 5, affinity: TextAffinity.upstream)); - }, [TargetPlatform.macOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.macOS)); - testWidgetsWithPlatform( - 'Can select last separated character in paragraph on iOS', + testWidgets('Can select last separated character in paragraph on iOS', (tester) async { const text = 'Test.'; final document = ParchmentDocument.fromJson([ @@ -644,9 +646,9 @@ void main() { editor.selection, const TextSelection.collapsed( offset: text.length, affinity: TextAffinity.upstream)); - }, [TargetPlatform.iOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); - testWidgetsWithPlatform( + testWidgets( 'Tapping after the beginning of a word moves cursor after word on iOS', (tester) async { final editor = EditorSandBox(tester: tester, autofocus: true); @@ -658,9 +660,9 @@ void main() { editor.selection, const TextSelection.collapsed( offset: 4, affinity: TextAffinity.upstream)); - }, [TargetPlatform.iOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); - testWidgetsWithPlatform( + testWidgets( 'Tapping before the beginning of a word moves cursor at the end of previous word on iOS', (tester) async { final document = ParchmentDocument.fromJson([ @@ -679,7 +681,7 @@ void main() { editor.selection, const TextSelection.collapsed( offset: 3, affinity: TextAffinity.upstream)); - }, [TargetPlatform.iOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); testWidgets( 'Tapping moves the cursor right where user tapped on other platforms', @@ -699,7 +701,7 @@ void main() { offset: 1, affinity: TextAffinity.upstream)); }); - testWidgetsWithPlatform('selection handles for iOS', (tester) async { + testWidgets('selection handles for iOS', (tester) async { final document = ParchmentDocument(); final editor = EditorSandBox(tester: tester, document: document, autofocus: true); @@ -707,9 +709,9 @@ void main() { final rawEditor = tester.widget(find.byType(RawEditor)); expect(rawEditor.selectionControls, const TypeMatcher()); - }, [TargetPlatform.iOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); - testWidgetsWithPlatform('selection handles for macOS', (tester) async { + testWidgets('selection handles for macOS', (tester) async { final document = ParchmentDocument(); final editor = EditorSandBox(tester: tester, document: document, autofocus: true); @@ -717,9 +719,9 @@ void main() { final rawEditor = tester.widget(find.byType(RawEditor)); expect(rawEditor.selectionControls, const TypeMatcher()); - }, [TargetPlatform.macOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.macOS)); - testWidgetsWithPlatform('selection handles for Android', (tester) async { + testWidgets('selection handles for Android', (tester) async { final document = ParchmentDocument(); final editor = EditorSandBox(tester: tester, document: document, autofocus: true); @@ -727,9 +729,9 @@ void main() { final rawEditor = tester.widget(find.byType(RawEditor)); expect(rawEditor.selectionControls, const TypeMatcher()); - }, [TargetPlatform.android]); + }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgetsWithPlatform( + testWidgets( 'show single selection handle when setting cursor position (Android)', (tester) async { final document = ParchmentDocument.fromJson([ @@ -744,7 +746,7 @@ void main() { await tester.pump(); final handleOverlays = find.byType(SelectionHandleOverlay); expect(handleOverlays, findsOneWidget); - }, [TargetPlatform.android]); + }, variant: TargetPlatformVariant.only(TargetPlatform.android)); testWidgets('dragging collapsed selection shows magnifier', (tester) async { @@ -827,7 +829,7 @@ void main() { expect(magnifier, findsNothing); }); - testWidgetsWithPlatform('selection handles for Windows', (tester) async { + testWidgets('selection handles for Windows', (tester) async { final document = ParchmentDocument(); final editor = EditorSandBox(tester: tester, document: document, autofocus: true); @@ -835,9 +837,9 @@ void main() { final rawEditor = tester.widget(find.byType(RawEditor)); expect(rawEditor.selectionControls, const TypeMatcher()); - }, [TargetPlatform.windows]); + }, variant: TargetPlatformVariant.only(TargetPlatform.windows)); - testWidgetsWithPlatform('selection handles for Linux', (tester) async { + testWidgets('selection handles for Linux', (tester) async { final document = ParchmentDocument(); final editor = EditorSandBox(tester: tester, document: document, autofocus: true); @@ -845,9 +847,9 @@ void main() { final rawEditor = tester.widget(find.byType(RawEditor)); expect(rawEditor.selectionControls, const TypeMatcher()); - }, [TargetPlatform.linux]); + }, variant: TargetPlatformVariant.only(TargetPlatform.linux)); - testWidgetsWithPlatform('selectAll for macOS', (tester) async { + testWidgets('selectAll for macOS', (tester) async { final document = ParchmentDocument.fromJson([ {'insert': 'Test\nAnother line\n'} ]); @@ -870,9 +872,9 @@ void main() { extentOffset: 17, affinity: TextAffinity.upstream)); expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsNothing); - }, [TargetPlatform.macOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.macOS)); - testWidgetsWithPlatform('selectAll for Windows/Linux', (tester) async { + testWidgets('selectAll for Windows/Linux', (tester) async { final document = ParchmentDocument.fromJson([ {'insert': 'Test\nAnother line\n'} ]); @@ -893,10 +895,11 @@ void main() { extentOffset: 17, affinity: TextAffinity.upstream)); expect(find.byType(DesktopTextSelectionToolbar), findsNothing); - }, [TargetPlatform.linux, TargetPlatform.windows]); + }, + variant: const TargetPlatformVariant( + {TargetPlatform.linux, TargetPlatform.windows})); - testWidgetsWithPlatform( - 'Triple tap selects paragraph on platforms other than Linux', + testWidgets('Triple tap selects paragraph on platforms other than Linux', (tester) async { const text = 'This is a relatively long paragraph with multiple lines that' @@ -921,10 +924,9 @@ void main() { baseOffset: 0, extentOffset: 117, affinity: TextAffinity.upstream)); - }, [TargetPlatform.macOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.macOS)); - testWidgetsWithPlatform('Triple tap selects a line on Linux', - (tester) async { + testWidgets('Triple tap selects a line on Linux', (tester) async { const text = 'This is a relatively long paragraph with multiple lines that' ' we are going to triple tap on it in order to select it.'; @@ -948,7 +950,7 @@ void main() { baseOffset: 0, extentOffset: 50, affinity: TextAffinity.upstream)); - }, [TargetPlatform.linux]); + }, variant: TargetPlatformVariant.only(TargetPlatform.linux)); testWidgets( 'Arrow keys move cursor to next/previous line at correct position', @@ -1106,7 +1108,7 @@ void main() { return editor; } - testWidgetsWithPlatform('suggests correction on initial load (Android)', + testWidgets('suggests correction on initial load (Android)', (tester) async { spellCheckService.stub = (_, __) async { return [ @@ -1131,10 +1133,9 @@ void main() { await tester.pump(); expect( find.byType(FleatherSpellCheckSuggestionsToolbar), findsOneWidget); - }, [TargetPlatform.android]); + }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgetsWithPlatform('suggests correction on initial load (iOS)', - (tester) async { + testWidgets('suggests correction on initial load (iOS)', (tester) async { spellCheckService.stub = (_, __) async { return [ const SuggestionSpan( @@ -1153,10 +1154,10 @@ void main() { await tester.pump(); expect(find.byType(FleatherCupertinoSpellCheckSuggestionsToolbar), findsOneWidget); - }, [TargetPlatform.iOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); - testWidgetsWithPlatform( - 'replaces text with selected suggestion (Android)', (tester) async { + testWidgets('replaces text with selected suggestion (Android)', + (tester) async { spellCheckService.stub = (_, __) async { return [ const SuggestionSpan( @@ -1181,10 +1182,9 @@ void main() { await tester.tap(find.text('Some')); await tester.pump(throttleDuration); expect(editor.controller.document.toPlainText(), 'Some text\n'); - }, [TargetPlatform.android]); + }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgetsWithPlatform('deletes erroneous text (Android)', - (tester) async { + testWidgets('deletes erroneous text (Android)', (tester) async { spellCheckService.stub = (_, __) async { return [ const SuggestionSpan( @@ -1211,9 +1211,9 @@ void main() { .toUpperCase())); await tester.pump(throttleDuration); expect(editor.controller.document.toPlainText(), 'Sole text\n'); - }, [TargetPlatform.android]); + }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgetsWithPlatform('replaces text with selected suggestion (iOS)', + testWidgets('replaces text with selected suggestion (iOS)', (tester) async { spellCheckService.stub = (_, __) async { return [ @@ -1234,7 +1234,7 @@ void main() { await tester.tap(find.text('Some')); await tester.pump(throttleDuration); expect(editor.controller.document.toPlainText(), 'Some text\n'); - }, [TargetPlatform.iOS]); + }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); }); group('didUpdateWidget', () { @@ -1308,18 +1308,6 @@ void prepareClipboard() { }); } -@isTest -Future testWidgetsWithPlatform(String description, - WidgetTesterCallback callback, List platforms) async { - testWidgets(description, (tester) async { - for (final platform in platforms) { - debugDefaultTargetPlatformOverride = platform; - await callback(tester); - } - debugDefaultTargetPlatformOverride = null; - }); -} - Future sendPasteIntent(WidgetTester tester) => (Actions.invoke( tester.state(find.byType(FleatherKeyboardListener)).context, const PasteTextIntent(SelectionChangedCause.longPress)) as Future);