chore: upgrade Flutter to 3.22.0 (#797)

This commit is contained in:
Lucas.Xu 2024-05-14 14:05:38 +08:00 • committed by GitHub
commit 796d1249fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 122 additions and 100 deletions

View file

@ -33,7 +33,7 @@ jobs:
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
channel: "stable" channel: "stable"
flutter-version: "3.19.0" flutter-version: "3.22.0"
cache: true cache: true
- name: Run tests - name: Run tests

View file

@ -217,8 +217,8 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
height: 36, height: 36,
child: TextButton( child: TextButton(
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(const Color(0xFF00BCF0)), backgroundColor: WidgetStateProperty.all(const Color(0xFF00BCF0)),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape: WidgetStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0), borderRadius: BorderRadius.circular(12.0),
), ),

View file

@ -44,14 +44,14 @@ class _SelectionMenuItemWidgetState extends State<SelectionMenuItemWidget> {
), ),
style: ButtonStyle( style: ButtonStyle(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
overlayColor: MaterialStateProperty.all( overlayColor: WidgetStateProperty.all(
style.selectionMenuItemSelectedColor, style.selectionMenuItemSelectedColor,
), ),
backgroundColor: widget.isSelected backgroundColor: widget.isSelected
? MaterialStateProperty.all( ? WidgetStateProperty.all(
style.selectionMenuItemSelectedColor, style.selectionMenuItemSelectedColor,
) )
: MaterialStateProperty.all(Colors.transparent), : WidgetStateProperty.all(Colors.transparent),
), ),
label: Text( label: Text(
widget.item.name, widget.item.name,

View file

@ -169,9 +169,9 @@ class ResetColorButton extends StatelessWidget {
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>( backgroundColor: WidgetStateProperty.resolveWith<Color>(
(Set<MaterialState> states) { (Set<WidgetState> states) {
if (states.contains(MaterialState.hovered)) { if (states.contains(WidgetState.hovered)) {
return Theme.of(context).hoverColor; return Theme.of(context).hoverColor;
} }
return Colors.transparent; return Colors.transparent;

View file

@ -3,9 +3,9 @@ import 'package:flutter/material.dart';
ButtonStyle buildOverlayButtonStyle(BuildContext context) { ButtonStyle buildOverlayButtonStyle(BuildContext context) {
return ButtonStyle( return ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>( backgroundColor: WidgetStateProperty.resolveWith<Color>(
(Set<MaterialState> states) { (Set<WidgetState> states) {
if (states.contains(MaterialState.hovered)) { if (states.contains(WidgetState.hovered)) {
return Theme.of(context).hoverColor; return Theme.of(context).hoverColor;
} }
return Colors.transparent; return Colors.transparent;

View file

@ -123,20 +123,20 @@ class _MobileLinkMenuState extends State<MobileLinkMenu> {
widget.onCancel.call(); widget.onCancel.call();
}, },
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.all( backgroundColor: WidgetStateProperty.all(
style.backgroundColor, style.backgroundColor,
), ),
foregroundColor: MaterialStateProperty.all( foregroundColor: WidgetStateProperty.all(
style.primaryColor, style.primaryColor,
), ),
elevation: MaterialStateProperty.all(0), elevation: WidgetStateProperty.all(0),
shape: MaterialStateProperty.all( shape: WidgetStateProperty.all(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: borderRadius:
BorderRadius.circular(style.borderRadius), BorderRadius.circular(style.borderRadius),
), ),
), ),
side: MaterialStateBorderSide.resolveWith( side: WidgetStateBorderSide.resolveWith(
(states) => BorderSide(color: style.outlineColor), (states) => BorderSide(color: style.outlineColor),
), ),
), ),
@ -154,14 +154,14 @@ class _MobileLinkMenuState extends State<MobileLinkMenu> {
?.closeKeyboard(); ?.closeKeyboard();
}, },
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.all( backgroundColor: WidgetStateProperty.all(
style.primaryColor, style.primaryColor,
), ),
foregroundColor: MaterialStateProperty.all( foregroundColor: WidgetStateProperty.all(
style.onPrimaryColor, style.onPrimaryColor,
), ),
elevation: MaterialStateProperty.all(0), elevation: WidgetStateProperty.all(0),
shape: MaterialStateProperty.all( shape: WidgetStateProperty.all(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: borderRadius:
BorderRadius.circular(style.borderRadius), BorderRadius.circular(style.borderRadius),

View file

@ -22,9 +22,9 @@ class MobileToolbarItemMenuBtn extends StatelessWidget {
onPressed: onPressed, onPressed: onPressed,
style: ButtonStyle( style: ButtonStyle(
alignment: label == null ? Alignment.center : Alignment.centerLeft, alignment: label == null ? Alignment.center : Alignment.centerLeft,
foregroundColor: MaterialStateProperty.all(style.foregroundColor), foregroundColor: WidgetStateProperty.all(style.foregroundColor),
splashFactory: NoSplash.splashFactory, splashFactory: NoSplash.splashFactory,
side: MaterialStateProperty.resolveWith<BorderSide>( side: WidgetStateProperty.resolveWith<BorderSide>(
(states) { (states) {
if (isSelected == true) { if (isSelected == true) {
return BorderSide( return BorderSide(
@ -35,12 +35,12 @@ class MobileToolbarItemMenuBtn extends StatelessWidget {
return BorderSide(color: style.itemOutlineColor); return BorderSide(color: style.itemOutlineColor);
}, },
), ),
shape: MaterialStateProperty.all( shape: WidgetStateProperty.all(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(style.borderRadius), borderRadius: BorderRadius.circular(style.borderRadius),
), ),
), ),
padding: MaterialStateProperty.all( padding: WidgetStateProperty.all(
EdgeInsets.zero, EdgeInsets.zero,
), ),
), ),

View file

@ -19,7 +19,7 @@ platforms:
environment: environment:
sdk: ">=3.1.5 <4.0.0" sdk: ">=3.1.5 <4.0.0"
flutter: ">=3.13.0" flutter: ">=3.19.0"
dependencies: dependencies:
flutter: flutter:
@ -33,7 +33,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_svg: ^2.0.6 flutter_svg: ^2.0.6
html: ^0.15.0 html: ^0.15.0
intl: ^0.18.0 intl: ^0.19.0
intl_utils: ^2.8.2 intl_utils: ^2.8.2
keyboard_height_plugin: ^0.0.4 keyboard_height_plugin: ^0.0.4
logging: ^1.2.0 logging: ^1.2.0
@ -52,7 +52,7 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^3.0.1 flutter_lints: ^4.0.0
network_image_mock: ^2.1.1 network_image_mock: ^2.1.1
mockito: ^5.4.1 mockito: ^5.4.1
leak_tracker: ^10.0.0 leak_tracker: ^10.0.0

View file

@ -30,7 +30,7 @@ void main() async {
startOffset: 0, startOffset: 0,
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.enter); await editor.pressKey(key: LogicalKeyboardKey.enter);
var selection = editor.selection!; var selection = editor.selection!;
var cell01 = getCellNode(tableNode.node, 0, 1)!; var cell01 = getCellNode(tableNode.node, 0, 1)!;
@ -59,7 +59,7 @@ void main() async {
startOffset: 0, startOffset: 0,
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.enter); await editor.pressKey(key: LogicalKeyboardKey.enter);
var selection = editor.selection!; var selection = editor.selection!;
@ -88,7 +88,8 @@ void main() async {
startOffset: 0, startOffset: 0,
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
await tester.pumpAndSettle();
var selection = editor.selection!; var selection = editor.selection!;
@ -123,7 +124,7 @@ void main() async {
// ), // ),
// ), // ),
// ); // );
// await simulateKeyDownEvent(LogicalKeyboardKey.backspace); // await editor.pressKey(key: LogicalKeyboardKey.backspace);
// var selection = editor.selection!; // var selection = editor.selection!;
@ -165,7 +166,7 @@ void main() async {
), ),
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
var selection = editor.selection!; var selection = editor.selection!;
@ -204,7 +205,7 @@ void main() async {
), ),
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
var selection = editor.selection!; var selection = editor.selection!;
@ -237,7 +238,7 @@ void main() async {
startOffset: 1, startOffset: 1,
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowUp); await editor.pressKey(key: LogicalKeyboardKey.arrowUp);
var selection = editor.selection!; var selection = editor.selection!;
@ -251,7 +252,7 @@ void main() async {
startOffset: 3, startOffset: 3,
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowUp); await editor.pressKey(key: LogicalKeyboardKey.arrowUp);
selection = editor.selection!; selection = editor.selection!;
@ -281,7 +282,7 @@ void main() async {
startOffset: 1, startOffset: 1,
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowDown); await editor.pressKey(key: LogicalKeyboardKey.arrowDown);
var selection = editor.selection!; var selection = editor.selection!;
@ -295,7 +296,7 @@ void main() async {
startOffset: 3, startOffset: 3,
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowDown); await editor.pressKey(key: LogicalKeyboardKey.arrowDown);
selection = editor.selection!; selection = editor.selection!;
@ -325,7 +326,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
var selection = editor.selection!; var selection = editor.selection!;
@ -340,7 +341,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
selection = editor.selection!; selection = editor.selection!;
@ -370,7 +371,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
var selection = editor.selection!; var selection = editor.selection!;
@ -400,7 +401,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowRight); await editor.pressKey(key: LogicalKeyboardKey.arrowRight);
var selection = editor.selection!; var selection = editor.selection!;
@ -432,7 +433,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowRight); await editor.pressKey(key: LogicalKeyboardKey.arrowRight);
var selection = editor.selection!; var selection = editor.selection!;
@ -448,7 +449,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.arrowRight); await editor.pressKey(key: LogicalKeyboardKey.arrowRight);
selection = editor.selection!; selection = editor.selection!;
@ -480,7 +481,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.tab); await editor.pressKey(key: LogicalKeyboardKey.tab);
var selection = editor.selection!; var selection = editor.selection!;
@ -495,7 +496,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.tab); await editor.pressKey(key: LogicalKeyboardKey.tab);
selection = editor.selection!; selection = editor.selection!;
@ -511,7 +512,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.tab); await editor.pressKey(key: LogicalKeyboardKey.tab);
selection = editor.selection!; selection = editor.selection!;
@ -543,8 +544,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.shiftLeft); await editor.pressKey(key: LogicalKeyboardKey.tab, isShiftPressed: true);
await simulateKeyDownEvent(LogicalKeyboardKey.tab);
var selection = editor.selection!; var selection = editor.selection!;
@ -559,8 +559,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.shiftLeft); await editor.pressKey(key: LogicalKeyboardKey.tab, isShiftPressed: true);
await simulateKeyDownEvent(LogicalKeyboardKey.tab);
selection = editor.selection!; selection = editor.selection!;
@ -576,8 +575,7 @@ void main() async {
), ),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.shiftLeft); await editor.pressKey(key: LogicalKeyboardKey.tab, isShiftPressed: true);
await simulateKeyDownEvent(LogicalKeyboardKey.tab);
selection = editor.selection!; selection = editor.selection!;

View file

@ -466,7 +466,7 @@ void main() {
.indentPadding(node, TextDirection.ltr), .indentPadding(node, TextDirection.ltr),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
nestedBlock = nestedBlock =

View file

@ -234,6 +234,7 @@ class TestableEditor {
LogicalKeyboardKey.asterisk: '*', LogicalKeyboardKey.asterisk: '*',
LogicalKeyboardKey.underscore: '_', LogicalKeyboardKey.underscore: '_',
}; };
Future<void> pressKey({ Future<void> pressKey({
String? character, String? character,
LogicalKeyboardKey? key, LogicalKeyboardKey? key,

View file

@ -71,13 +71,13 @@ void main() async {
// move the cursor to the beginning of node 1 // move the cursor to the beginning of node 1
for (var i = 1; i < text.length; i++) { for (var i = 1; i < text.length; i++) {
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
expect(editor.selection, Selection.collapsed(Position(path: [1]))); expect(editor.selection, Selection.collapsed(Position(path: [1])));
// move the cursor to the ending of node 0 // move the cursor to the ending of node 0
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
expect( expect(
editor.selection, editor.selection,
Selection.collapsed(Position(path: [0], offset: text.length)), Selection.collapsed(Position(path: [0], offset: text.length)),
@ -85,7 +85,7 @@ void main() async {
// move the cursor to the beginning of node 0 // move the cursor to the beginning of node 0
for (var i = 1; i < text.length; i++) { for (var i = 1; i < text.length; i++) {
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
expect(editor.selection, Selection.collapsed(Position(path: [0]))); expect(editor.selection, Selection.collapsed(Position(path: [0])));

View file

@ -73,7 +73,7 @@ void main() async {
// move the cursor to the ending of node 0 // move the cursor to the ending of node 0
for (var i = 1; i < text.length; i++) { for (var i = 1; i < text.length; i++) {
await simulateKeyDownEvent(LogicalKeyboardKey.arrowRight); await editor.pressKey(key: LogicalKeyboardKey.arrowRight);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
expect( expect(
@ -82,12 +82,12 @@ void main() async {
); );
// move the cursor to the beginning of node 1 // move the cursor to the beginning of node 1
await simulateKeyDownEvent(LogicalKeyboardKey.arrowRight); await editor.pressKey(key: LogicalKeyboardKey.arrowRight);
expect(editor.selection, Selection.collapsed(Position(path: [1]))); expect(editor.selection, Selection.collapsed(Position(path: [1])));
// move the cursor to the ending of node 1 // move the cursor to the ending of node 1
for (var i = 1; i < text.length; i++) { for (var i = 1; i < text.length; i++) {
await simulateKeyDownEvent(LogicalKeyboardKey.arrowRight); await editor.pressKey(key: LogicalKeyboardKey.arrowRight);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
expect( expect(

View file

@ -319,7 +319,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// the first node should be deleted. // the first node should be deleted.
@ -366,7 +366,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
@ -416,7 +416,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
@ -453,7 +453,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
@ -495,7 +495,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.backspace); await editor.pressKey(key: LogicalKeyboardKey.backspace);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
node = editor.nodeAtPath([1])!; node = editor.nodeAtPath([1])!;

View file

@ -289,7 +289,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.delete); await editor.pressKey(key: LogicalKeyboardKey.delete);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// the first node should be deleted. // the first node should be deleted.
@ -336,7 +336,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.delete); await editor.pressKey(key: LogicalKeyboardKey.delete);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
@ -386,7 +386,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.delete); await editor.pressKey(key: LogicalKeyboardKey.delete);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
@ -424,7 +424,7 @@ void main() async {
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.delete); await editor.pressKey(key: LogicalKeyboardKey.delete);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(

View file

@ -35,7 +35,7 @@ void main() async {
await editor.updateSelection(selection); await editor.updateSelection(selection);
for (final LogicalKeyboardKey key in keys) { for (final LogicalKeyboardKey key in keys) {
await simulateKeyDownEvent(key); await editor.pressKey(key: key);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
@ -84,7 +84,7 @@ void main() async {
await editor.updateSelection(selection); await editor.updateSelection(selection);
for (final LogicalKeyboardKey key in keys) { for (final LogicalKeyboardKey key in keys) {
await simulateKeyDownEvent(key); await editor.pressKey(key: key);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
@ -136,7 +136,7 @@ void main() async {
await editor.updateSelection(selection); await editor.updateSelection(selection);
for (final LogicalKeyboardKey key in keys) { for (final LogicalKeyboardKey key in keys) {
await simulateKeyDownEvent(key); await editor.pressKey(key: key);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
@ -175,7 +175,7 @@ void main() async {
await editor.updateSelection(selection); await editor.updateSelection(selection);
for (final LogicalKeyboardKey key in keys) { for (final LogicalKeyboardKey key in keys) {
await simulateKeyDownEvent(key); await editor.pressKey(key: key);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
@ -219,7 +219,7 @@ void main() async {
await editor.updateSelection(selection); await editor.updateSelection(selection);
for (final LogicalKeyboardKey key in keys) { for (final LogicalKeyboardKey key in keys) {
await simulateKeyDownEvent(key); await editor.pressKey(key: key);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }

View file

@ -1,4 +1,5 @@
import 'dart:io' show Platform; import 'dart:io' show Platform;
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
@ -25,7 +26,7 @@ void main() async {
final selection = Selection.collapsed(Position(path: [0])); final selection = Selection.collapsed(Position(path: [0]));
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.end); await editor.pressKey(key: LogicalKeyboardKey.end);
if (Platform.isWindows || Platform.isLinux) { if (Platform.isWindows || Platform.isLinux) {
expect( expect(
@ -50,7 +51,7 @@ void main() async {
final selection = Selection.collapsed(Position(path: [5])); final selection = Selection.collapsed(Position(path: [5]));
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.end); await editor.pressKey(key: LogicalKeyboardKey.end);
if (Platform.isWindows || Platform.isLinux) { if (Platform.isWindows || Platform.isLinux) {
expect( expect(

View file

@ -1,4 +1,5 @@
import 'dart:io' show Platform; import 'dart:io' show Platform;
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
@ -27,7 +28,7 @@ void main() async {
Selection.collapsed(Position(path: [0], offset: text.length)); Selection.collapsed(Position(path: [0], offset: text.length));
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.home); await editor.pressKey(key: LogicalKeyboardKey.home);
if (Platform.isWindows || Platform.isLinux) { if (Platform.isWindows || Platform.isLinux) {
expect( expect(
@ -53,7 +54,7 @@ void main() async {
Selection.collapsed(Position(path: [5], offset: text.length)); Selection.collapsed(Position(path: [5], offset: text.length));
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.home); await editor.pressKey(key: LogicalKeyboardKey.home);
if (Platform.isWindows || Platform.isLinux) { if (Platform.isWindows || Platform.isLinux) {
expect( expect(

View file

@ -1,8 +1,6 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../../infra/testable_editor.dart'; import '../../../infra/testable_editor.dart';
@ -51,7 +49,7 @@ void main() async {
('خط دوم', blockComponentTextDirectionRTL), ('خط دوم', blockComponentTextDirectionRTL),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.tab); await editor.pressKey(key: LogicalKeyboardKey.tab);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final node = editor.nodeAtPath([0])!; final node = editor.nodeAtPath([0])!;
@ -71,7 +69,7 @@ void main() async {
('خط دوم', blockComponentTextDirectionRTL), ('خط دوم', blockComponentTextDirectionRTL),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.tab); await editor.pressKey(key: LogicalKeyboardKey.tab);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final node = editor.nodeAtPath([0])!; final node = editor.nodeAtPath([0])!;
@ -91,7 +89,7 @@ void main() async {
('خط دوم', blockComponentTextDirectionAuto), ('خط دوم', blockComponentTextDirectionAuto),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.tab); await editor.pressKey(key: LogicalKeyboardKey.tab);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final node = editor.nodeAtPath([0])!; final node = editor.nodeAtPath([0])!;
@ -116,7 +114,7 @@ void main() async {
('س', blockComponentTextDirectionAuto), ('س', blockComponentTextDirectionAuto),
); );
await simulateKeyDownEvent(LogicalKeyboardKey.tab); await editor.pressKey(key: LogicalKeyboardKey.tab);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
Node node = editor.nodeAtPath([0])!; Node node = editor.nodeAtPath([0])!;
@ -163,7 +161,7 @@ Future<TestableEditor> indentTestHelper(
); );
await editor.updateSelection(selection); await editor.updateSelection(selection);
await simulateKeyDownEvent(LogicalKeyboardKey.tab); await editor.pressKey(key: LogicalKeyboardKey.tab);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final node = editor.nodeAtPath([0])!; final node = editor.nodeAtPath([0])!;

View file

@ -1,7 +1,8 @@
import 'dart:io';
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'dart:io';
import '../../../infra/testable_editor.dart'; import '../../../infra/testable_editor.dart';
@ -98,13 +99,13 @@ void main() async {
// move the cursor to the beginning of node 1 // move the cursor to the beginning of node 1
for (var i = 1; i < text.length; i++) { for (var i = 1; i < text.length; i++) {
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
expect(editor.selection, Selection.collapsed(Position(path: [1]))); expect(editor.selection, Selection.collapsed(Position(path: [1])));
// move the cursor to the ending of node 0 // move the cursor to the ending of node 0
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
expect( expect(
editor.selection, editor.selection,
Selection.collapsed(Position(path: [0], offset: text.length)), Selection.collapsed(Position(path: [0], offset: text.length)),
@ -112,7 +113,7 @@ void main() async {
// move the cursor to the beginning of node 0 // move the cursor to the beginning of node 0
for (var i = 1; i < text.length; i++) { for (var i = 1; i < text.length; i++) {
await simulateKeyDownEvent(LogicalKeyboardKey.arrowLeft); await editor.pressKey(key: LogicalKeyboardKey.arrowLeft);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
expect(editor.selection, Selection.collapsed(Position(path: [0]))); expect(editor.selection, Selection.collapsed(Position(path: [0])));

Some files were not shown because too many files have changed in this diff Show more