committed by
GitHub
parent
23c7ee9deb
commit
b93f71f9c8
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
@TestOn('!chrome') // This whole test suite needs triage.
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as ui show window, BoxHeightStyle, BoxWidthStyle;
|
||||
@@ -31,7 +29,7 @@ class MockClipboard {
|
||||
case 'Clipboard.getData':
|
||||
return _clipboardData;
|
||||
case 'Clipboard.setData':
|
||||
_clipboardData = methodCall.arguments;
|
||||
_clipboardData = methodCall.arguments as Object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +57,7 @@ class WidgetsLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocaliza
|
||||
bool shouldReload(WidgetsLocalizationsDelegate old) => false;
|
||||
}
|
||||
|
||||
Widget overlay({ Widget child }) {
|
||||
Widget overlay({ required Widget child }) {
|
||||
final OverlayEntry entry = OverlayEntry(
|
||||
builder: (BuildContext context) {
|
||||
return Center(
|
||||
@@ -93,7 +91,7 @@ Widget overlayWithEntry(OverlayEntry entry) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget boilerplate({ Widget child }) {
|
||||
Widget boilerplate({ required Widget child }) {
|
||||
return MaterialApp(
|
||||
home: Localizations(
|
||||
locale: const Locale('en', 'US'),
|
||||
@@ -154,8 +152,8 @@ void main() {
|
||||
|
||||
final Key textFieldKey = UniqueKey();
|
||||
Widget textFieldBuilder({
|
||||
int maxLines = 1,
|
||||
int minLines,
|
||||
int? maxLines = 1,
|
||||
int? minLines,
|
||||
}) {
|
||||
return boilerplate(
|
||||
child: TextField(
|
||||
@@ -192,7 +190,7 @@ void main() {
|
||||
|
||||
testWidgets('TextField has consistent size', (WidgetTester tester) async {
|
||||
final Key textFieldKey = UniqueKey();
|
||||
String textFieldValue;
|
||||
late String textFieldValue;
|
||||
|
||||
await tester.pumpWidget(
|
||||
overlay(
|
||||
@@ -288,24 +286,24 @@ void main() {
|
||||
final EditableTextState editableTextState = tester.firstState(find.byType(EditableText));
|
||||
final RenderEditable renderEditable = editableTextState.renderEditable;
|
||||
|
||||
expect(renderEditable.cursorColor.alpha, 255);
|
||||
expect(renderEditable.cursorColor!.alpha, 255);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
|
||||
expect(renderEditable.cursorColor.alpha, 255);
|
||||
expect(renderEditable.cursorColor!.alpha, 255);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(renderEditable.cursorColor.alpha, 110);
|
||||
expect(renderEditable.cursorColor!.alpha, 110);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(renderEditable.cursorColor.alpha, 16);
|
||||
expect(renderEditable.cursorColor!.alpha, 16);
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
expect(renderEditable.cursorColor.alpha, 0);
|
||||
expect(renderEditable.cursorColor!.alpha, 0);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('Cursor radius is 2.0', (WidgetTester tester) async {
|
||||
@@ -400,7 +398,7 @@ void main() {
|
||||
await expectLater(
|
||||
find.byKey(const ValueKey<int>(1)),
|
||||
matchesGoldenFile(
|
||||
'text_field_cursor_test_${describeEnum(debugDefaultTargetPlatformOverride).toLowerCase()}.material.1.png',
|
||||
'text_field_cursor_test_${describeEnum(debugDefaultTargetPlatformOverride!).toLowerCase()}.material.1.png',
|
||||
),
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
@@ -812,12 +810,12 @@ void main() {
|
||||
|
||||
await tester.pump();
|
||||
|
||||
String editText = findRenderEditable(tester).text.text;
|
||||
String editText = findRenderEditable(tester).text!.text!;
|
||||
expect(editText.substring(editText.length - 1), newChar);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
|
||||
editText = findRenderEditable(tester).text.text;
|
||||
editText = findRenderEditable(tester).text!.text!;
|
||||
expect(editText.substring(editText.length - 1), '\u2022');
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.android }));
|
||||
|
||||
@@ -852,7 +850,7 @@ void main() {
|
||||
|
||||
await tester.pump();
|
||||
|
||||
final String editText = findRenderEditable(tester).text.text;
|
||||
final String editText = findRenderEditable(tester).text!.text!;
|
||||
expect(editText.substring(editText.length - 1), '\u2022');
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{
|
||||
TargetPlatform.macOS,
|
||||
@@ -1105,7 +1103,7 @@ void main() {
|
||||
expect(tester.testTextInput.hasAnyClients, false);
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
// Collapse selection should not paint.
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
// Long press on the 'd' character of text 'readOnly' to show context menu.
|
||||
const int dIndex = 3;
|
||||
final Offset dPos = textOffsetToPosition(tester, dIndex);
|
||||
@@ -1184,7 +1182,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
final EditableTextState state = tester.state(find.byType(EditableText));
|
||||
TextSelection currentOverlaySelection =
|
||||
state.selectionOverlay.value.selection;
|
||||
state.selectionOverlay!.value.selection;
|
||||
expect(currentOverlaySelection.baseOffset, 0);
|
||||
expect(currentOverlaySelection.extentOffset, 8);
|
||||
|
||||
@@ -1200,7 +1198,7 @@ void main() {
|
||||
entry.markNeedsBuild();
|
||||
|
||||
await tester.pump();
|
||||
currentOverlaySelection = state.selectionOverlay.value.selection;
|
||||
currentOverlaySelection = state.selectionOverlay!.value.selection;
|
||||
expect(currentOverlaySelection.baseOffset, 1);
|
||||
expect(currentOverlaySelection.extentOffset, 7);
|
||||
});
|
||||
@@ -1224,7 +1222,7 @@ void main() {
|
||||
|
||||
final RenderEditable renderEditable = findRenderEditable(tester);
|
||||
// There should be no composing.
|
||||
expect(renderEditable.text, TextSpan(text:'readonly', style: renderEditable.text.style));
|
||||
expect(renderEditable.text, TextSpan(text:'readonly', style: renderEditable.text!.style));
|
||||
});
|
||||
|
||||
testWidgets('Dynamically switching between read only and not read only should hide or show collapse cursor', (WidgetTester tester) async {
|
||||
@@ -1248,18 +1246,18 @@ void main() {
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
// Collapse selection should not paint.
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
|
||||
readOnly = false;
|
||||
// Mark entry to be dirty in order to trigger overlay update.
|
||||
entry.markNeedsBuild();
|
||||
await tester.pumpAndSettle();
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isTrue);
|
||||
|
||||
readOnly = true;
|
||||
entry.markNeedsBuild();
|
||||
await tester.pumpAndSettle();
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Dynamically switching to read only should close input connection', (WidgetTester tester) async {
|
||||
@@ -1854,13 +1852,12 @@ void main() {
|
||||
|
||||
// Toolbar should fade in. Starting at 0% opacity.
|
||||
final Element target = tester.element(find.text('Select all'));
|
||||
final FadeTransition opacity = target.findAncestorWidgetOfExactType<FadeTransition>();
|
||||
expect(opacity, isNotNull);
|
||||
final FadeTransition opacity = target.findAncestorWidgetOfExactType<FadeTransition>()!;
|
||||
expect(opacity.opacity.value, equals(0.0));
|
||||
|
||||
// Still fading in.
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
final FadeTransition opacity2 = target.findAncestorWidgetOfExactType<FadeTransition>();
|
||||
final FadeTransition opacity2 = target.findAncestorWidgetOfExactType<FadeTransition>()!;
|
||||
expect(opacity, same(opacity2));
|
||||
expect(opacity.opacity.value, greaterThan(0.0));
|
||||
expect(opacity.opacity.value, lessThan(1.0));
|
||||
@@ -2098,8 +2095,8 @@ void main() {
|
||||
|
||||
testWidgets('Multiline text when wrapped in Expanded', (WidgetTester tester) async {
|
||||
Widget expandedTextFieldBuilder({
|
||||
int maxLines = 1,
|
||||
int minLines,
|
||||
int? maxLines = 1,
|
||||
int? minLines,
|
||||
bool expands = false,
|
||||
}) {
|
||||
return boilerplate(
|
||||
@@ -2191,7 +2188,7 @@ void main() {
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/pull/29093
|
||||
testWidgets('errorText empty string', (WidgetTester tester) async {
|
||||
Widget textFormFieldBuilder(String errorText) {
|
||||
Widget textFormFieldBuilder(String? errorText) {
|
||||
return boilerplate(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -2240,10 +2237,10 @@ void main() {
|
||||
const double padding = 24.0;
|
||||
|
||||
Widget containedTextFieldBuilder({
|
||||
Widget counter,
|
||||
String helperText,
|
||||
String labelText,
|
||||
Widget prefix,
|
||||
Widget? counter,
|
||||
String? helperText,
|
||||
String? labelText,
|
||||
Widget? prefix,
|
||||
}) {
|
||||
return boilerplate(
|
||||
child: Container(
|
||||
@@ -2346,7 +2343,7 @@ void main() {
|
||||
testWidgets('Multiline hint text will wrap up to maxLines', (WidgetTester tester) async {
|
||||
final Key textFieldKey = UniqueKey();
|
||||
|
||||
Widget builder(int maxLines, final String hintMsg) {
|
||||
Widget builder(int? maxLines, final String hintMsg) {
|
||||
return boilerplate(
|
||||
child: TextField(
|
||||
key: textFieldKey,
|
||||
@@ -2562,7 +2559,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('TextField smoke test', (WidgetTester tester) async {
|
||||
String textFieldValue;
|
||||
late String textFieldValue;
|
||||
|
||||
await tester.pumpWidget(
|
||||
overlay(
|
||||
@@ -2591,7 +2588,7 @@ void main() {
|
||||
|
||||
testWidgets('TextField with global key', (WidgetTester tester) async {
|
||||
final GlobalKey textFieldKey = GlobalKey(debugLabel: 'textFieldKey');
|
||||
String textFieldValue;
|
||||
late String textFieldValue;
|
||||
|
||||
await tester.pumpWidget(
|
||||
overlay(
|
||||
@@ -2649,8 +2646,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
final Text helperText = tester.widget(find.text('helper text'));
|
||||
expect(helperText.style.color, themeData.hintColor);
|
||||
expect(helperText.style.fontSize, Typography.englishLike2014.caption.fontSize);
|
||||
expect(helperText.style!.color, themeData.hintColor);
|
||||
expect(helperText.style!.fontSize, Typography.englishLike2014.caption!.fontSize);
|
||||
});
|
||||
|
||||
testWidgets('TextField with specified helperStyle', (WidgetTester tester) async {
|
||||
@@ -2698,8 +2695,8 @@ void main() {
|
||||
);
|
||||
|
||||
final Text hintText = tester.widget(find.text('Placeholder'));
|
||||
expect(hintText.style.color, themeData.hintColor);
|
||||
expect(hintText.style.fontSize, style.fontSize);
|
||||
expect(hintText.style!.color, themeData.hintColor);
|
||||
expect(hintText.style!.fontSize, style.fontSize);
|
||||
});
|
||||
|
||||
testWidgets('TextField with specified hintStyle', (WidgetTester tester) async {
|
||||
@@ -3088,8 +3085,8 @@ void main() {
|
||||
text: 'More Text',
|
||||
);
|
||||
|
||||
TextEditingController currentController;
|
||||
StateSetter setState;
|
||||
TextEditingController? currentController;
|
||||
late StateSetter setState;
|
||||
|
||||
await tester.pumpWidget(
|
||||
overlay(
|
||||
@@ -3106,61 +3103,61 @@ void main() {
|
||||
// Initial state with null controller.
|
||||
await tester.tap(find.byType(TextField));
|
||||
await tester.pump();
|
||||
expect(tester.testTextInput.editingState['text'], isEmpty);
|
||||
expect(tester.testTextInput.editingState!['text'], isEmpty);
|
||||
|
||||
// Update the controller from null to controller1.
|
||||
setState(() {
|
||||
currentController = controller1;
|
||||
});
|
||||
await tester.pump();
|
||||
expect(tester.testTextInput.editingState['text'], equals('Initial Text'));
|
||||
expect(tester.testTextInput.editingState!['text'], equals('Initial Text'));
|
||||
|
||||
// Verify that updates to controller1 are handled.
|
||||
controller1.text = 'Updated Text';
|
||||
await tester.idle();
|
||||
expect(tester.testTextInput.editingState['text'], equals('Updated Text'));
|
||||
expect(tester.testTextInput.editingState!['text'], equals('Updated Text'));
|
||||
|
||||
// Verify that switching from controller1 to controller2 is handled.
|
||||
setState(() {
|
||||
currentController = controller2;
|
||||
});
|
||||
await tester.pump();
|
||||
expect(tester.testTextInput.editingState['text'], equals('More Text'));
|
||||
expect(tester.testTextInput.editingState!['text'], equals('More Text'));
|
||||
|
||||
// Verify that updates to controller1 are ignored.
|
||||
controller1.text = 'Ignored Text';
|
||||
await tester.idle();
|
||||
expect(tester.testTextInput.editingState['text'], equals('More Text'));
|
||||
expect(tester.testTextInput.editingState!['text'], equals('More Text'));
|
||||
|
||||
// Verify that updates to controller text are handled.
|
||||
controller2.text = 'Additional Text';
|
||||
await tester.idle();
|
||||
expect(tester.testTextInput.editingState['text'], equals('Additional Text'));
|
||||
expect(tester.testTextInput.editingState!['text'], equals('Additional Text'));
|
||||
|
||||
// Verify that updates to controller selection are handled.
|
||||
controller2.selection = const TextSelection(baseOffset: 0, extentOffset: 5);
|
||||
await tester.idle();
|
||||
expect(tester.testTextInput.editingState['selectionBase'], equals(0));
|
||||
expect(tester.testTextInput.editingState['selectionExtent'], equals(5));
|
||||
expect(tester.testTextInput.editingState!['selectionBase'], equals(0));
|
||||
expect(tester.testTextInput.editingState!['selectionExtent'], equals(5));
|
||||
|
||||
// Verify that calling clear() clears the text.
|
||||
controller2.clear();
|
||||
await tester.idle();
|
||||
expect(tester.testTextInput.editingState['text'], equals(''));
|
||||
expect(tester.testTextInput.editingState!['text'], equals(''));
|
||||
|
||||
// Verify that switching from controller2 to null preserves current text.
|
||||
controller2.text = 'The Final Cut';
|
||||
await tester.idle();
|
||||
expect(tester.testTextInput.editingState['text'], equals('The Final Cut'));
|
||||
expect(tester.testTextInput.editingState!['text'], equals('The Final Cut'));
|
||||
setState(() {
|
||||
currentController = null;
|
||||
});
|
||||
await tester.pump();
|
||||
expect(tester.testTextInput.editingState['text'], equals('The Final Cut'));
|
||||
expect(tester.testTextInput.editingState!['text'], equals('The Final Cut'));
|
||||
|
||||
// Verify that changes to controller2 are ignored.
|
||||
controller2.text = 'Goodbye Cruel World';
|
||||
expect(tester.testTextInput.editingState['text'], equals('The Final Cut'));
|
||||
expect(tester.testTextInput.editingState!['text'], equals('The Final Cut'));
|
||||
});
|
||||
|
||||
testWidgets('Cannot enter new lines onto single line TextField', (WidgetTester tester) async {
|
||||
@@ -3482,13 +3479,12 @@ void main() {
|
||||
expect(controller.selection.start, lessThanOrEqualTo(0));
|
||||
expect(controller.selection.end, lessThanOrEqualTo(0));
|
||||
|
||||
FlutterError error;
|
||||
late FlutterError error;
|
||||
try {
|
||||
controller.selection = const TextSelection.collapsed(offset: 10);
|
||||
} on FlutterError catch (e) {
|
||||
error = e;
|
||||
} finally {
|
||||
expect(error, isNotNull);
|
||||
expect(error.diagnostics.length, 1);
|
||||
expect(
|
||||
error.toStringDeep(),
|
||||
@@ -3686,7 +3682,7 @@ void main() {
|
||||
expect(textController.text, '0123456789101112');
|
||||
expect(find.text('16/10'), findsOneWidget);
|
||||
Text counterTextWidget = tester.widget(find.text('16/10'));
|
||||
expect(counterTextWidget.style.color, equals(Colors.deepPurpleAccent));
|
||||
expect(counterTextWidget.style!.color, equals(Colors.deepPurpleAccent));
|
||||
|
||||
await tester.enterText(find.byType(TextField), '0123456789');
|
||||
await tester.pump();
|
||||
@@ -3694,7 +3690,7 @@ void main() {
|
||||
expect(textController.text, '0123456789');
|
||||
expect(find.text('10/10'), findsOneWidget);
|
||||
counterTextWidget = tester.widget(find.text('10/10'));
|
||||
expect(counterTextWidget.style.color, isNot(equals(Colors.deepPurpleAccent)));
|
||||
expect(counterTextWidget.style!.color, isNot(equals(Colors.deepPurpleAccent)));
|
||||
});
|
||||
|
||||
testWidgets('maxLength shows warning when maxLengthEnforced is false with surrogate pairs.', (WidgetTester tester) async {
|
||||
@@ -3716,7 +3712,7 @@ void main() {
|
||||
expect(textController.text, '😆012345678910111');
|
||||
expect(find.text('16/10'), findsOneWidget);
|
||||
Text counterTextWidget = tester.widget(find.text('16/10'));
|
||||
expect(counterTextWidget.style.color, equals(Colors.deepPurpleAccent));
|
||||
expect(counterTextWidget.style!.color, equals(Colors.deepPurpleAccent));
|
||||
|
||||
await tester.enterText(find.byType(TextField), '😆012345678');
|
||||
await tester.pump();
|
||||
@@ -3724,7 +3720,7 @@ void main() {
|
||||
expect(textController.text, '😆012345678');
|
||||
expect(find.text('10/10'), findsOneWidget);
|
||||
counterTextWidget = tester.widget(find.text('10/10'));
|
||||
expect(counterTextWidget.style.color, isNot(equals(Colors.deepPurpleAccent)));
|
||||
expect(counterTextWidget.style!.color, isNot(equals(Colors.deepPurpleAccent)));
|
||||
});
|
||||
|
||||
testWidgets('maxLength shows warning when maxLengthEnforced is false with grapheme clusters.', (WidgetTester tester) async {
|
||||
@@ -3746,7 +3742,7 @@ void main() {
|
||||
expect(textController.text, '👨👩👦012345678910111');
|
||||
expect(find.text('16/10'), findsOneWidget);
|
||||
Text counterTextWidget = tester.widget(find.text('16/10'));
|
||||
expect(counterTextWidget.style.color, equals(Colors.deepPurpleAccent));
|
||||
expect(counterTextWidget.style!.color, equals(Colors.deepPurpleAccent));
|
||||
|
||||
await tester.enterText(find.byType(TextField), '👨👩👦012345678');
|
||||
await tester.pump();
|
||||
@@ -3754,7 +3750,7 @@ void main() {
|
||||
expect(textController.text, '👨👩👦012345678');
|
||||
expect(find.text('10/10'), findsOneWidget);
|
||||
counterTextWidget = tester.widget(find.text('10/10'));
|
||||
expect(counterTextWidget.style.color, isNot(equals(Colors.deepPurpleAccent)));
|
||||
expect(counterTextWidget.style!.color, isNot(equals(Colors.deepPurpleAccent)));
|
||||
});
|
||||
|
||||
testWidgets('maxLength limits input with surrogate pairs.', (WidgetTester tester) async {
|
||||
@@ -3874,7 +3870,7 @@ void main() {
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: TextField(
|
||||
buildCounter: (BuildContext context, { int currentLength, int maxLength, bool isFocused }) {
|
||||
buildCounter: (BuildContext context, { required int currentLength, int? maxLength, required bool isFocused }) {
|
||||
return Text('${currentLength.toString()} of ${maxLength.toString()}');
|
||||
},
|
||||
maxLength: 10,
|
||||
@@ -3958,25 +3954,25 @@ void main() {
|
||||
await tester.pumpWidget(buildFrame(true, false));
|
||||
Text helperWidget = tester.widget(find.text(helperText));
|
||||
Text counterWidget = tester.widget(find.text(counterText));
|
||||
expect(helperWidget.style.color, isNot(equals(Colors.transparent)));
|
||||
expect(counterWidget.style.color, isNot(equals(Colors.transparent)));
|
||||
expect(helperWidget.style!.color, isNot(equals(Colors.transparent)));
|
||||
expect(counterWidget.style!.color, isNot(equals(Colors.transparent)));
|
||||
await tester.pumpWidget(buildFrame(true, true));
|
||||
counterWidget = tester.widget(find.text(counterText));
|
||||
Text errorWidget = tester.widget(find.text(errorText));
|
||||
expect(helperWidget.style.color, isNot(equals(Colors.transparent)));
|
||||
expect(errorWidget.style.color, isNot(equals(Colors.transparent)));
|
||||
expect(helperWidget.style!.color, isNot(equals(Colors.transparent)));
|
||||
expect(errorWidget.style!.color, isNot(equals(Colors.transparent)));
|
||||
|
||||
// When enabled is false, the helper/error and counter are not visible.
|
||||
await tester.pumpWidget(buildFrame(false, false));
|
||||
helperWidget = tester.widget(find.text(helperText));
|
||||
counterWidget = tester.widget(find.text(counterText));
|
||||
expect(helperWidget.style.color, equals(Colors.transparent));
|
||||
expect(counterWidget.style.color, equals(Colors.transparent));
|
||||
expect(helperWidget.style!.color, equals(Colors.transparent));
|
||||
expect(counterWidget.style!.color, equals(Colors.transparent));
|
||||
await tester.pumpWidget(buildFrame(false, true));
|
||||
errorWidget = tester.widget(find.text(errorText));
|
||||
counterWidget = tester.widget(find.text(counterText));
|
||||
expect(counterWidget.style.color, equals(Colors.transparent));
|
||||
expect(errorWidget.style.color, equals(Colors.transparent));
|
||||
expect(counterWidget.style!.color, equals(Colors.transparent));
|
||||
expect(errorWidget.style!.color, equals(Colors.transparent));
|
||||
});
|
||||
|
||||
testWidgets('currentValueLength/maxValueLength are in the tree', (WidgetTester tester) async {
|
||||
@@ -4083,7 +4079,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Keyboard Tests', () {
|
||||
TextEditingController controller;
|
||||
late TextEditingController controller;
|
||||
|
||||
setUp( () {
|
||||
controller = TextEditingController();
|
||||
@@ -4644,7 +4640,6 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
const String testValue = 'a big house';
|
||||
await tester.enterText(find.byType(TextField).first, testValue);
|
||||
await tester.idle();
|
||||
@@ -5170,7 +5165,7 @@ void main() {
|
||||
|
||||
testWidgets('TextField change selection with semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner;
|
||||
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner!;
|
||||
final TextEditingController controller = TextEditingController()
|
||||
..text = 'Hello';
|
||||
final Key key = UniqueKey();
|
||||
@@ -5269,7 +5264,7 @@ void main() {
|
||||
const String textInTextField = 'Hello';
|
||||
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner;
|
||||
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner!;
|
||||
final TextEditingController controller = TextEditingController()
|
||||
..text = textInTextField;
|
||||
final Key key = UniqueKey();
|
||||
@@ -5338,7 +5333,7 @@ void main() {
|
||||
const String textInTextField = 'Hello';
|
||||
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner;
|
||||
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner!;
|
||||
final TextEditingController controller = TextEditingController()
|
||||
..text = textInTextField;
|
||||
final Key key = UniqueKey();
|
||||
@@ -5444,7 +5439,7 @@ void main() {
|
||||
boilerplate(
|
||||
child: Builder(builder: (BuildContext context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
data: MediaQuery.of(context)!.copyWith(
|
||||
navigationMode: NavigationMode.directional,
|
||||
),
|
||||
child: TextField(
|
||||
@@ -5465,7 +5460,7 @@ void main() {
|
||||
boilerplate(
|
||||
child: Builder(builder: (BuildContext context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
data: MediaQuery.of(context)!.copyWith(
|
||||
navigationMode: NavigationMode.directional,
|
||||
),
|
||||
child: TextField(
|
||||
@@ -5741,8 +5736,8 @@ void main() {
|
||||
final Key textField2 = UniqueKey();
|
||||
final ScrollController scrollController = ScrollController();
|
||||
|
||||
double minOffset;
|
||||
double maxOffset;
|
||||
double? minOffset;
|
||||
double? maxOffset;
|
||||
|
||||
scrollController.addListener(() {
|
||||
final double offset = scrollController.offset;
|
||||
@@ -5814,8 +5809,8 @@ void main() {
|
||||
final Key textField2 = UniqueKey();
|
||||
final ScrollController scrollController = ScrollController();
|
||||
|
||||
double minOffset;
|
||||
double maxOffset;
|
||||
double? minOffset;
|
||||
double? maxOffset;
|
||||
|
||||
scrollController.addListener(() {
|
||||
final double offset = scrollController.offset;
|
||||
@@ -5925,9 +5920,9 @@ void main() {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/24612
|
||||
|
||||
Widget buildFrame({
|
||||
double stepWidth,
|
||||
double cursorWidth,
|
||||
TextAlign textAlign,
|
||||
double? stepWidth,
|
||||
required double cursorWidth,
|
||||
required TextAlign textAlign,
|
||||
}) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -5952,7 +5947,7 @@ void main() {
|
||||
// A cursor of default size doesn't cause the TextField to increase its
|
||||
// width.
|
||||
const String text = '1234';
|
||||
double stepWidth = 80.0;
|
||||
double? stepWidth = 80.0;
|
||||
await tester.pumpWidget(buildFrame(
|
||||
stepWidth: 80.0,
|
||||
cursorWidth: 2.0,
|
||||
@@ -6022,12 +6017,12 @@ void main() {
|
||||
// Empty TextStyle is overridden by theme
|
||||
await tester.pumpWidget(buildFrame(const TextStyle()));
|
||||
EditableText editableText = tester.widget(find.byType(EditableText));
|
||||
expect(editableText.style.color, themeData.textTheme.subtitle1.color);
|
||||
expect(editableText.style.background, themeData.textTheme.subtitle1.background);
|
||||
expect(editableText.style.shadows, themeData.textTheme.subtitle1.shadows);
|
||||
expect(editableText.style.decoration, themeData.textTheme.subtitle1.decoration);
|
||||
expect(editableText.style.locale, themeData.textTheme.subtitle1.locale);
|
||||
expect(editableText.style.wordSpacing, themeData.textTheme.subtitle1.wordSpacing);
|
||||
expect(editableText.style.color, themeData.textTheme.subtitle1!.color);
|
||||
expect(editableText.style.background, themeData.textTheme.subtitle1!.background);
|
||||
expect(editableText.style.shadows, themeData.textTheme.subtitle1!.shadows);
|
||||
expect(editableText.style.decoration, themeData.textTheme.subtitle1!.decoration);
|
||||
expect(editableText.style.locale, themeData.textTheme.subtitle1!.locale);
|
||||
expect(editableText.style.wordSpacing, themeData.textTheme.subtitle1!.wordSpacing);
|
||||
|
||||
// Properties set on TextStyle override theme
|
||||
const Color setColor = Colors.red;
|
||||
@@ -7570,8 +7565,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
@@ -7592,8 +7587,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -7615,8 +7610,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isTrue);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
@@ -7637,8 +7632,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isTrue);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -7662,8 +7657,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isTrue);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
@@ -7686,8 +7681,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isTrue);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -7719,8 +7714,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -7752,8 +7747,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -7789,8 +7784,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -7819,7 +7814,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final EditableTextState state = tester.state(find.byType(EditableText));
|
||||
expect(state.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(state.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
expect(controller.selection, const TextSelection.collapsed(offset: 0));
|
||||
|
||||
if (kIsWeb) {
|
||||
@@ -7832,7 +7827,7 @@ void main() {
|
||||
state.currentTextEditingValue.selection,
|
||||
const TextSelection(baseOffset: 2, extentOffset: 7),
|
||||
);
|
||||
expect(state.selectionOverlay.handlesAreVisible, isFalse);
|
||||
expect(state.selectionOverlay!.handlesAreVisible, isFalse);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7855,8 +7850,8 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final EditableTextState editableText = tester.state(find.byType(EditableText));
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay.handlesAreVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.handlesAreVisible, isTrue);
|
||||
|
||||
final RenderEditable renderEditable = findRenderEditable(tester);
|
||||
final List<TextSelectionPoint> endpoints = globalize(
|
||||
@@ -7868,11 +7863,11 @@ void main() {
|
||||
// Tap the handle to show the toolbar.
|
||||
final Offset handlePos = endpoints[0].point + const Offset(0.0, 1.0);
|
||||
await tester.tapAt(handlePos, pointer: 7);
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isTrue);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isTrue);
|
||||
|
||||
// Tap the handle again to hide the toolbar.
|
||||
await tester.tapAt(handlePos, pointer: 7);
|
||||
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
|
||||
expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('when TextField would be blocked by keyboard, it is shown with enough space for the selection handle', (WidgetTester tester) async {
|
||||
@@ -7954,7 +7949,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('intrinsics', () {
|
||||
Widget _buildTest({ bool isDense }) {
|
||||
Widget _buildTest({ required bool isDense }) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: CustomScrollView(
|
||||
@@ -8099,7 +8094,7 @@ void main() {
|
||||
TextField(
|
||||
key: textField2Key,
|
||||
maxLength: 1,
|
||||
buildCounter: (BuildContext context, {int currentLength, bool isFocused, int maxLength}) => null,
|
||||
buildCounter: (BuildContext context, {required int currentLength, required bool isFocused, int? maxLength}) => null,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -8228,7 +8223,7 @@ void main() {
|
||||
|
||||
await tester.pump();
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.grab);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.grab);
|
||||
|
||||
// Test default cursor
|
||||
await tester.pumpWidget(
|
||||
@@ -8246,9 +8241,9 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
await gesture.moveTo(edge);
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
await gesture.moveTo(center);
|
||||
|
||||
// Test default cursor when disabled
|
||||
@@ -8268,14 +8263,14 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
await gesture.moveTo(edge);
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
await gesture.moveTo(center);
|
||||
});
|
||||
|
||||
testWidgets('Caret rtl with changing width', (WidgetTester tester) async {
|
||||
StateSetter setState;
|
||||
late StateSetter setState;
|
||||
bool isWide = false;
|
||||
const double wideWidth = 300.0;
|
||||
const double narrowWidth = 200.0;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -173,7 +171,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('onChanged callbacks are called', (WidgetTester tester) async {
|
||||
String _value;
|
||||
late String _value;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -203,7 +201,7 @@ void main() {
|
||||
child: Center(
|
||||
child: TextFormField(
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (String value) {
|
||||
validator: (String? value) {
|
||||
_validateCalled++;
|
||||
return null;
|
||||
},
|
||||
@@ -229,7 +227,7 @@ void main() {
|
||||
child: TextFormField(
|
||||
enabled: true,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (String value) {
|
||||
validator: (String? value) {
|
||||
_validateCalled += 1;
|
||||
return null;
|
||||
},
|
||||
@@ -272,25 +270,25 @@ void main() {
|
||||
await tester.pumpWidget(buildFrame(true, false));
|
||||
Text helperWidget = tester.widget(find.text(helperText));
|
||||
Text counterWidget = tester.widget(find.text(counterText));
|
||||
expect(helperWidget.style.color, isNot(equals(Colors.transparent)));
|
||||
expect(counterWidget.style.color, isNot(equals(Colors.transparent)));
|
||||
expect(helperWidget.style!.color, isNot(equals(Colors.transparent)));
|
||||
expect(counterWidget.style!.color, isNot(equals(Colors.transparent)));
|
||||
await tester.pumpWidget(buildFrame(true, true));
|
||||
counterWidget = tester.widget(find.text(counterText));
|
||||
Text errorWidget = tester.widget(find.text(errorText));
|
||||
expect(helperWidget.style.color, isNot(equals(Colors.transparent)));
|
||||
expect(errorWidget.style.color, isNot(equals(Colors.transparent)));
|
||||
expect(helperWidget.style!.color, isNot(equals(Colors.transparent)));
|
||||
expect(errorWidget.style!.color, isNot(equals(Colors.transparent)));
|
||||
|
||||
// When enabled is false, the helper/error and counter are not visible.
|
||||
await tester.pumpWidget(buildFrame(false, false));
|
||||
helperWidget = tester.widget(find.text(helperText));
|
||||
counterWidget = tester.widget(find.text(counterText));
|
||||
expect(helperWidget.style.color, equals(Colors.transparent));
|
||||
expect(counterWidget.style.color, equals(Colors.transparent));
|
||||
expect(helperWidget.style!.color, equals(Colors.transparent));
|
||||
expect(counterWidget.style!.color, equals(Colors.transparent));
|
||||
await tester.pumpWidget(buildFrame(false, true));
|
||||
errorWidget = tester.widget(find.text(errorText));
|
||||
counterWidget = tester.widget(find.text(counterText));
|
||||
expect(counterWidget.style.color, equals(Colors.transparent));
|
||||
expect(errorWidget.style.color, equals(Colors.transparent));
|
||||
expect(counterWidget.style!.color, equals(Colors.transparent));
|
||||
expect(errorWidget.style!.color, equals(Colors.transparent));
|
||||
});
|
||||
|
||||
testWidgets('passing a buildCounter shows returned widget', (WidgetTester tester) async {
|
||||
@@ -298,7 +296,7 @@ void main() {
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: TextFormField(
|
||||
buildCounter: (BuildContext context, { int currentLength, int maxLength, bool isFocused }) {
|
||||
buildCounter: (BuildContext context, { int? currentLength, int? maxLength, bool? isFocused }) {
|
||||
return Text('${currentLength.toString()} of ${maxLength.toString()}');
|
||||
},
|
||||
maxLength: 10,
|
||||
@@ -434,7 +432,7 @@ void main() {
|
||||
testWidgets('onChanged callbacks value and FormFieldState.value are sync', (WidgetTester tester) async {
|
||||
bool _called = false;
|
||||
|
||||
FormFieldState<String> state;
|
||||
late FormFieldState<String> state;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -484,7 +482,7 @@ void main() {
|
||||
child: Scaffold(
|
||||
body: TextFormField(
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: (String value) {
|
||||
validator: (String? value) {
|
||||
_validateCalled++;
|
||||
return null;
|
||||
},
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
@@ -21,7 +19,7 @@ class MockClipboard {
|
||||
case 'Clipboard.getData':
|
||||
return _clipboardData;
|
||||
case 'Clipboard.setData':
|
||||
_clipboardData = methodCall.arguments;
|
||||
_clipboardData = methodCall.arguments as Object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -38,9 +36,9 @@ void main() {
|
||||
|
||||
group('canSelectAll', () {
|
||||
Widget createEditableText({
|
||||
Key key,
|
||||
String text,
|
||||
TextSelection selection,
|
||||
required Key key,
|
||||
String? text,
|
||||
TextSelection? selection,
|
||||
}) {
|
||||
final TextEditingController controller = TextEditingController(text: text)
|
||||
..selection = selection ?? const TextSelection.collapsed(offset: -1);
|
||||
@@ -59,7 +57,7 @@ void main() {
|
||||
testWidgets('should return false when there is no text', (WidgetTester tester) async {
|
||||
final GlobalKey<EditableTextState> key = GlobalKey();
|
||||
await tester.pumpWidget(createEditableText(key: key));
|
||||
expect(materialTextSelectionControls.canSelectAll(key.currentState), false);
|
||||
expect(materialTextSelectionControls.canSelectAll(key.currentState!), false);
|
||||
});
|
||||
|
||||
testWidgets('should return true when there is text and collapsed selection', (WidgetTester tester) async {
|
||||
@@ -68,7 +66,7 @@ void main() {
|
||||
key: key,
|
||||
text: '123',
|
||||
));
|
||||
expect(materialTextSelectionControls.canSelectAll(key.currentState), true);
|
||||
expect(materialTextSelectionControls.canSelectAll(key.currentState!), true);
|
||||
});
|
||||
|
||||
testWidgets('should return true when there is text and partial uncollapsed selection', (WidgetTester tester) async {
|
||||
@@ -78,7 +76,7 @@ void main() {
|
||||
text: '123',
|
||||
selection: const TextSelection(baseOffset: 1, extentOffset: 2),
|
||||
));
|
||||
expect(materialTextSelectionControls.canSelectAll(key.currentState), true);
|
||||
expect(materialTextSelectionControls.canSelectAll(key.currentState!), true);
|
||||
});
|
||||
|
||||
testWidgets('should return false when there is text and full selection', (WidgetTester tester) async {
|
||||
@@ -88,7 +86,7 @@ void main() {
|
||||
text: '123',
|
||||
selection: const TextSelection(baseOffset: 0, extentOffset: 3),
|
||||
));
|
||||
expect(materialTextSelectionControls.canSelectAll(key.currentState), false);
|
||||
expect(materialTextSelectionControls.canSelectAll(key.currentState!), false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
@@ -74,7 +72,7 @@ void main() {
|
||||
final EditableTextState editableTextState = tester.firstState(find.byType(EditableText));
|
||||
final RenderEditable renderEditable = editableTextState.renderEditable;
|
||||
expect(renderEditable.cursorColor, defaultCursorColor);
|
||||
expect(Color(renderEditable.selectionColor.value), defaultSelectionColor);
|
||||
expect(Color(renderEditable.selectionColor!.value), defaultSelectionColor);
|
||||
|
||||
// Test the selection handle color.
|
||||
await tester.pumpWidget(
|
||||
@@ -117,7 +115,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
final EditableTextState editableTextState = tester.firstState(find.byType(EditableText));
|
||||
final RenderEditable renderEditable = editableTextState.renderEditable;
|
||||
expect(renderEditable.cursorColor, textSelectionTheme.cursorColor.withAlpha(0));
|
||||
expect(renderEditable.cursorColor, textSelectionTheme.cursorColor!.withAlpha(0));
|
||||
expect(renderEditable.selectionColor, textSelectionTheme.selectionColor);
|
||||
|
||||
// Test the selection handle color.
|
||||
@@ -170,7 +168,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
final EditableTextState editableTextState = tester.firstState(find.byType(EditableText));
|
||||
final RenderEditable renderEditable = editableTextState.renderEditable;
|
||||
expect(renderEditable.cursorColor, widgetTextSelectionTheme.cursorColor.withAlpha(0));
|
||||
expect(renderEditable.cursorColor, widgetTextSelectionTheme.cursorColor!.withAlpha(0));
|
||||
expect(renderEditable.selectionColor, widgetTextSelectionTheme.selectionColor);
|
||||
|
||||
// Test the selection handle color.
|
||||
|
||||
Reference in New Issue
Block a user