Remove Material import from editable text cursor tests (#186671)
Part of flutter/flutter#177412
Refs flutter/flutter#177028
This removes the Material dependency from
widgets/editable_text_cursor_test.dart by replacing MaterialApp wrappers
with TestWidgetsApp, using explicit Color/TextStyle constants instead of
Material Colors/Typography, replacing material text selection controls
with the widgets test controls plus a small paste-only context menu, and
replacing the Material TextField smoke case with an equivalent
EditableText setup.
Validation:
- dart analyze
packages/flutter/test/widgets/editable_text_cursor_test.dart
- ./bin/flutter test
packages/flutter/test/widgets/editable_text_cursor_test.dart
---------
Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
diff --git a/dev/bots/check_tests_cross_imports.dart b/dev/bots/check_tests_cross_imports.dart
index ec4dde3..cbc3f2c 100644
--- a/dev/bots/check_tests_cross_imports.dart
+++ b/dev/bots/check_tests_cross_imports.dart
@@ -119,7 +119,6 @@
'packages/flutter/test/widgets/inherited_test.dart',
'packages/flutter/test/widgets/heroes_test.dart',
'packages/flutter/test/widgets/drawer_test.dart',
- 'packages/flutter/test/widgets/editable_text_cursor_test.dart',
'packages/flutter/test/widgets/nested_scroll_view_test.dart',
'packages/flutter/test/widgets/scrollable_selection_test.dart',
'packages/flutter/test/widgets/page_transitions_builder_test.dart',
diff --git a/packages/flutter/test/widgets/editable_text_cursor_test.dart b/packages/flutter/test/widgets/editable_text_cursor_test.dart
index bb8aa4f..4291fe4 100644
--- a/packages/flutter/test/widgets/editable_text_cursor_test.dart
+++ b/packages/flutter/test/widgets/editable_text_cursor_test.dart
@@ -11,16 +11,43 @@
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
-import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
+import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'editable_text_tester.dart';
import 'editable_text_utils.dart';
+import 'widgets_app_tester.dart';
const TextStyle textStyle = TextStyle();
const Color cursorColor = Color.fromARGB(0xFF, 0xFF, 0x00, 0x00);
+const Color _blue = Color(0xff2196f3);
+const Color _grey = Color(0xff9e9e9e);
+const Color _textFieldBackgroundCursorColor = Color(0xff999999);
+const Color _black87 = Color(0xdd000000);
+// These mirror the platform-specific titleMedium color and font-family layer
+// from Typography.material2018(). Leave geometry such as fontSize to the
+// surrounding text style; the cursor goldens rely on that inherited geometry.
+const TextStyle _materialTitleMediumStyle = TextStyle(
+ fontFamily: 'Roboto',
+ color: _black87,
+ decoration: TextDecoration.none,
+);
+const TextStyle _cupertinoTitleMediumStyle = TextStyle(
+ fontFamily: 'CupertinoSystemText',
+ color: _black87,
+ decoration: TextDecoration.none,
+);
+
+Widget _pasteOnlyContextMenuBuilder(BuildContext context, EditableTextState editableTextState) {
+ return GestureDetector(
+ onTap: () async {
+ await editableTextState.pasteText(SelectionChangedCause.toolbar);
+ },
+ child: const Text('Paste'),
+ );
+}
void main() {
late TextEditingController controller;
@@ -49,7 +76,7 @@
child: Directionality(
textDirection: TextDirection.ltr,
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: textStyle,
@@ -73,17 +100,18 @@
final editableTextKey = GlobalKey<EditableTextState>();
late String changedValue;
- final Widget widget = MaterialApp(
+ final Widget widget = TestWidgetsApp(
home: RepaintBoundary(
key: const ValueKey<int>(1),
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
key: editableTextKey,
controller: controller,
focusNode: focusNode,
- style: Typography.material2018().black.titleMedium!,
- cursorColor: Colors.blue,
- selectionControls: materialTextSelectionControls,
+ style: _materialTitleMediumStyle,
+ cursorColor: _blue,
+ selectionControls: testTextSelectionHandleControls,
+ contextMenuBuilder: _pasteOnlyContextMenuBuilder,
keyboardType: TextInputType.text,
onChanged: (String value) {
changedValue = value;
@@ -130,17 +158,18 @@
final editableTextKey = GlobalKey<EditableTextState>();
late String changedValue;
- final Widget widget = MaterialApp(
+ final Widget widget = TestWidgetsApp(
home: RepaintBoundary(
key: const ValueKey<int>(1),
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
key: editableTextKey,
controller: controller,
focusNode: focusNode,
- style: Typography.material2018().black.titleMedium!,
- cursorColor: Colors.blue,
- selectionControls: materialTextSelectionControls,
+ style: _materialTitleMediumStyle,
+ cursorColor: _blue,
+ selectionControls: testTextSelectionHandleControls,
+ contextMenuBuilder: _pasteOnlyContextMenuBuilder,
keyboardType: TextInputType.text,
onChanged: (String value) {
changedValue = value;
@@ -184,9 +213,7 @@
});
testWidgets('Cursor can animate', (WidgetTester tester) async {
- await tester.pumpWidget(
- const MaterialApp(home: Material(child: TestTextField(cursorOpacityAnimates: true))),
- );
+ await tester.pumpWidget(const TestWidgetsApp(home: TestTextField(cursorOpacityAnimates: true)));
final Finder textFinder = find.byType(TestTextField);
await tester.tap(textFinder);
@@ -232,12 +259,10 @@
testWidgets('Cursor is static when cursorOpacityAnimates is false', (WidgetTester tester) async {
await tester.pumpWidget(
- const MaterialApp(
- home: Material(
- child: TestTextField(
- // cursorOpacityAnimates: false, default value.
- maxLines: 3,
- ),
+ const TestWidgetsApp(
+ home: TestTextField(
+ // cursorOpacityAnimates: false, default value.
+ maxLines: 3,
),
),
);
@@ -258,14 +283,12 @@
'Cursor does not animate when EditableText.debugDeterministicCursor and cursorOpacityAnimates are true',
(WidgetTester tester) async {
EditableText.debugDeterministicCursor = true;
- final defaultCursorColor = Color(ThemeData.fallback().colorScheme.primary.value);
- final Widget widget = MaterialApp(
- home: Material(
- child: TestTextField(
- maxLines: 3,
- cursorColor: defaultCursorColor,
- cursorOpacityAnimates: true,
- ),
+ const Color defaultCursorColor = _blue;
+ const Widget widget = TestWidgetsApp(
+ home: TestTextField(
+ maxLines: 3,
+ cursorColor: defaultCursorColor,
+ cursorOpacityAnimates: true,
),
);
await tester.pumpWidget(widget);
@@ -297,92 +320,88 @@
},
);
- testWidgets(
- 'Cursor animation restarts when it is moved using keys on desktop',
- (WidgetTester tester) async {
- debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
+ testWidgets('Cursor animation restarts when it is moved using keys on desktop', (
+ WidgetTester tester,
+ ) async {
+ debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
- const testText = 'Some text long enough to move the cursor around';
- controller.text = testText;
+ const testText = 'Some text long enough to move the cursor around';
+ controller.text = testText;
- final Widget widget = MaterialApp(
- home: EditableText(
- controller: controller,
- focusNode: focusNode,
- style: const TextStyle(fontSize: 20.0),
- cursorColor: Colors.blue,
- backgroundCursorColor: Colors.grey,
- selectionControls: materialTextSelectionControls,
- keyboardType: TextInputType.text,
- textAlign: TextAlign.left,
- ),
- );
- await tester.pumpWidget(widget);
+ final Widget widget = TestWidgetsApp(
+ home: EditableText(
+ controller: controller,
+ focusNode: focusNode,
+ style: const TextStyle(fontSize: 20.0),
+ cursorColor: _blue,
+ backgroundCursorColor: _grey,
+ selectionControls: testTextSelectionHandleControls,
+ keyboardType: TextInputType.text,
+ textAlign: TextAlign.left,
+ ),
+ );
+ await tester.pumpWidget(widget);
- await tester.tap(find.byType(EditableText));
- await tester.pump();
+ await tester.tap(find.byType(EditableText));
+ await tester.pump();
- final EditableTextState editableTextState = tester.firstState(find.byType(EditableText));
- final RenderEditable renderEditable = editableTextState.renderEditable;
+ final EditableTextState editableTextState = tester.firstState(find.byType(EditableText));
+ final RenderEditable renderEditable = editableTextState.renderEditable;
- await tester.pump();
- expect(renderEditable.cursorColor!.alpha, 255);
- expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
+ await tester.pump();
+ expect(renderEditable.cursorColor!.alpha, 255);
+ expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
- // Android cursor goes from exactly on to exactly off on the 500ms dot.
- await tester.pump(const Duration(milliseconds: 499));
- expect(renderEditable.cursorColor!.alpha, 255);
- expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
+ // Android cursor goes from exactly on to exactly off on the 500ms dot.
+ await tester.pump(const Duration(milliseconds: 499));
+ expect(renderEditable.cursorColor!.alpha, 255);
+ expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
- await tester.sendKeyDownEvent(LogicalKeyboardKey.arrowLeft);
- await tester.pump();
- await tester.sendKeyUpEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pump();
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.arrowLeft);
- await tester.pump();
- expect(renderEditable.cursorColor!.alpha, 255);
- expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
+ await tester.pump();
+ expect(renderEditable.cursorColor!.alpha, 255);
+ expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
- await tester.pump(const Duration(milliseconds: 200));
- expect(renderEditable.cursorColor!.alpha, 255);
- expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(renderEditable.cursorColor!.alpha, 255);
+ expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
- await tester.pump(const Duration(milliseconds: 299));
- expect(renderEditable.cursorColor!.alpha, 255);
- expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
+ await tester.pump(const Duration(milliseconds: 299));
+ expect(renderEditable.cursorColor!.alpha, 255);
+ expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
- await tester.sendKeyDownEvent(LogicalKeyboardKey.arrowRight);
- await tester.pump();
- await tester.sendKeyUpEvent(LogicalKeyboardKey.arrowRight);
- await tester.pump();
- await tester.sendKeyDownEvent(LogicalKeyboardKey.arrowRight);
- await tester.pump();
- await tester.sendKeyUpEvent(LogicalKeyboardKey.arrowRight);
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.arrowRight);
+ await tester.pump();
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.arrowRight);
+ await tester.pump();
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.arrowRight);
+ await tester.pump();
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.arrowRight);
- await tester.pump();
- expect(renderEditable.cursorColor!.alpha, 255);
- expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
+ await tester.pump();
+ expect(renderEditable.cursorColor!.alpha, 255);
+ expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
- await tester.pump(const Duration(milliseconds: 200));
- expect(renderEditable.cursorColor!.alpha, 255);
- expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(renderEditable.cursorColor!.alpha, 255);
+ expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
- await tester.pump(const Duration(milliseconds: 299));
- expect(renderEditable.cursorColor!.alpha, 255);
- expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
+ await tester.pump(const Duration(milliseconds: 299));
+ expect(renderEditable.cursorColor!.alpha, 255);
+ expect(renderEditable, paints..rect(color: const Color(0xff2196f3)));
- await tester.pump(const Duration(milliseconds: 1));
- expect(renderEditable.cursorColor!.alpha, 0);
- expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0));
+ await tester.pump(const Duration(milliseconds: 1));
+ expect(renderEditable.cursorColor!.alpha, 0);
+ expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0));
- debugDefaultTargetPlatformOverride = null;
- },
- variant: KeySimulatorTransitModeVariant.all(),
- );
+ debugDefaultTargetPlatformOverride = null;
+ }, variant: KeySimulatorTransitModeVariant.all());
testWidgets('Cursor does not show when showCursor set to false', (WidgetTester tester) async {
- const Widget widget = MaterialApp(
- home: Material(child: TestTextField(showCursor: false, maxLines: 3)),
- );
+ const Widget widget = TestWidgetsApp(home: TestTextField(showCursor: false, maxLines: 3));
await tester.pumpWidget(widget);
await tester.tap(find.byType(TestTextField));
@@ -405,9 +424,7 @@
testWidgets('Cursor does not show when not focused', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/106512 .
await tester.pumpWidget(
- MaterialApp(
- home: Material(child: TestTextField(focusNode: focusNode, autofocus: true)),
- ),
+ TestWidgetsApp(home: TestTextField(focusNode: focusNode, autofocus: true)),
);
assert(focusNode.hasFocus);
final EditableTextState editableTextState = tester.firstState(find.byType(EditableText));
@@ -445,7 +462,7 @@
node: focusScopeNode,
autofocus: true,
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: textStyle,
@@ -553,7 +570,7 @@
node: focusScopeNode,
autofocus: true,
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: textStyle,
@@ -609,7 +626,7 @@
node: focusScopeNode,
autofocus: true,
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: textStyle,
@@ -656,7 +673,7 @@
node: focusScopeNode,
autofocus: true,
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: textStyle,
@@ -736,7 +753,7 @@
textDirection: TextDirection.ltr,
child: EditableText(
key: key,
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
// Use animation controller to animate cursor blink for testing.
cursorOpacityAnimates: true,
controller: controller,
@@ -786,7 +803,7 @@
node: focusScopeNode,
autofocus: true,
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: textStyle,
@@ -854,7 +871,7 @@
node: focusScopeNode,
autofocus: true,
child: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
autofocus: true,
@@ -874,17 +891,21 @@
testWidgets(
'Floating cursor is painted',
(WidgetTester tester) async {
- const textStyle = TextStyle();
+ const textStyle = TextStyle(fontFamily: 'Roboto', fontSize: 16.0);
const text = 'hello world this is fun and cool and awesome!';
controller.text = text;
await tester.pumpWidget(
- MaterialApp(
- theme: ThemeData(useMaterial3: false),
+ TestWidgetsApp(
home: Padding(
padding: const EdgeInsets.only(top: 0.25),
- child: Material(
- child: TextField(controller: controller, focusNode: focusNode, style: textStyle),
+ child: EditableText(
+ controller: controller,
+ focusNode: focusNode,
+ style: textStyle,
+ cursorColor: _blue,
+ cursorRadius: const Radius.circular(2.0),
+ backgroundCursorColor: _textFieldBackgroundCursorColor,
),
),
),
@@ -900,16 +921,14 @@
);
await tester.pump();
+ // TestWidgetsApp leaves the EditableText origin on whole pixels instead
+ // of inheriting Material's fractional text field offset, so the odd-width
+ // floating cursor is centered on half-pixel x values.
expect(
editable,
paints..rrect(
rrect: RRect.fromRectAndRadius(
- const Rect.fromLTRB(
- 463.8333435058594,
- -0.916666666666668,
- 466.8333435058594,
- 19.083333969116211,
- ),
+ const Rect.fromLTRB(464.5, -0.916666666666668, 467.5, 19.083333969116211),
const Radius.circular(1.0),
),
color: const Color(0xbf2196f3),
@@ -928,7 +947,7 @@
find.byType(EditableText),
paints..rrect(
rrect: RRect.fromRectAndRadius(
- const Rect.fromLTWH(193.83334350585938, -0.916666666666668, 3.0, 20.0),
+ const Rect.fromLTWH(194.5, -0.916666666666668, 3.0, 20.0),
const Radius.circular(1.0),
),
color: const Color(0xbf2196f3),
@@ -945,10 +964,10 @@
paints
..rrect(
rrect: RRect.fromRectAndRadius(
- const Rect.fromLTWH(719.3333333333333, -0.9166666666666679, 2.0, 18.0),
+ const Rect.fromLTWH(720.0, -0.9166666666666679, 2.0, 18.0),
const Radius.circular(2.0),
),
- color: const Color(0xff999999),
+ color: _textFieldBackgroundCursorColor,
)
..rrect(
rrect: RRect.fromRectAndRadius(
@@ -978,20 +997,21 @@
final editableTextKey = GlobalKey<EditableTextState>();
late String changedValue;
- final Widget widget = MaterialApp(
+ final Widget widget = TestWidgetsApp(
home: RepaintBoundary(
key: const ValueKey<int>(1),
child: Column(
children: <Widget>[
const SizedBox(width: 10, height: 10),
EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
key: editableTextKey,
controller: controller,
focusNode: focusNode,
- style: Typography.material2018(platform: TargetPlatform.iOS).black.titleMedium!,
- cursorColor: Colors.blue,
- selectionControls: materialTextSelectionControls,
+ style: _cupertinoTitleMediumStyle,
+ cursorColor: _blue,
+ selectionControls: testTextSelectionHandleControls,
+ contextMenuBuilder: _pasteOnlyContextMenuBuilder,
keyboardType: TextInputType.text,
onChanged: (String value) {
changedValue = value;
@@ -1048,20 +1068,21 @@
final editableTextKey = GlobalKey<EditableTextState>();
late String changedValue;
- final Widget widget = MaterialApp(
+ final Widget widget = TestWidgetsApp(
home: RepaintBoundary(
key: const ValueKey<int>(1),
child: Column(
children: <Widget>[
const SizedBox(width: 10, height: 10),
EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
key: editableTextKey,
controller: controller,
focusNode: focusNode,
- style: Typography.material2018(platform: TargetPlatform.iOS).black.titleMedium!,
- cursorColor: Colors.blue,
- selectionControls: materialTextSelectionControls,
+ style: _cupertinoTitleMediumStyle,
+ cursorColor: _blue,
+ selectionControls: testTextSelectionHandleControls,
+ contextMenuBuilder: _pasteOnlyContextMenuBuilder,
keyboardType: TextInputType.text,
onChanged: (String value) {
changedValue = value;
@@ -1122,9 +1143,9 @@
});
await tester.pumpWidget(
- MaterialApp(
+ TestWidgetsApp(
home: EditableText(
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
obscureText: true,
focusNode: focusNode,
@@ -1168,7 +1189,7 @@
final Widget widget = EditableText(
autofocus: true,
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: const TextStyle(fontSize: 20),
@@ -1177,7 +1198,7 @@
cursorColor: cursorColor,
maxLines: null,
);
- await tester.pumpWidget(MaterialApp(home: widget));
+ await tester.pumpWidget(TestWidgetsApp(home: widget));
final EditableTextState editableTextState = tester.firstState(find.byWidget(widget));
final RenderEditable renderEditable = editableTextState.renderEditable;
@@ -1217,7 +1238,7 @@
final Widget widget = EditableText(
autofocus: true,
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: const TextStyle(fontSize: 17),
@@ -1228,7 +1249,7 @@
cursorHeight: 17.0,
maxLines: null,
);
- await tester.pumpWidget(MaterialApp(home: widget));
+ await tester.pumpWidget(TestWidgetsApp(home: widget));
final EditableTextState editableTextState = tester.firstState(find.byWidget(widget));
final Rect editableTextRect = tester.getRect(find.byWidget(widget));
@@ -1261,7 +1282,7 @@
final Widget widget = EditableText(
autofocus: true,
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: const TextStyle(fontSize: fontSize),
@@ -1270,7 +1291,7 @@
cursorHeight: cursorHeight,
cursorWidth: cursorWidth,
);
- await tester.pumpWidget(MaterialApp(home: widget));
+ await tester.pumpWidget(TestWidgetsApp(home: widget));
final EditableTextState editableTextState = tester.firstState(find.byWidget(widget));
final RenderEditable renderEditable = editableTextState.renderEditable;
@@ -1304,7 +1325,7 @@
final Widget widget = EditableText(
autofocus: true,
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: const TextStyle(fontSize: fontSize),
@@ -1313,7 +1334,7 @@
cursorHeight: cursorHeight,
cursorWidth: cursorWidth,
);
- await tester.pumpWidget(MaterialApp(home: widget));
+ await tester.pumpWidget(TestWidgetsApp(home: widget));
final EditableTextState editableTextState = tester.firstState(find.byWidget(widget));
final RenderEditable renderEditable = editableTextState.renderEditable;
@@ -1348,7 +1369,7 @@
final Widget widget = EditableText(
autofocus: true,
- backgroundCursorColor: Colors.grey,
+ backgroundCursorColor: _grey,
controller: controller,
focusNode: focusNode,
style: const TextStyle(fontSize: 20),
@@ -1357,7 +1378,7 @@
cursorColor: cursorColor,
maxLines: null,
);
- await tester.pumpWidget(MaterialApp(home: widget));
+ await tester.pumpWidget(TestWidgetsApp(home: widget));
final EditableTextState editableTextState = tester.firstState(find.byWidget(widget));
final Rect editableTextRect = tester.getRect(find.byWidget(widget));
@@ -1389,15 +1410,15 @@
controller.selection = const TextSelection.collapsed(offset: 0);
await tester.pumpWidget(
- MaterialApp(
+ TestWidgetsApp(
home: EditableText(
key: key,
autofocus: true,
controller: controller,
focusNode: focusNode,
style: textStyle,
- cursorColor: Colors.blue,
- backgroundCursorColor: Colors.grey,
+ cursorColor: _blue,
+ backgroundCursorColor: _grey,
cursorOpacityAnimates: true,
maxLines: 2,
),