Skip to content

Commit d041b31

Browse files
EditableText Cursor can be set to not blink for testing (flutter#20004)
* no blinking cursor * debugDeterministicCursor: private -> public * added documentation * whitespace
1 parent 5ea0a13 commit d041b31

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/flutter/lib/src/widgets/editable_text.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ class EditableText extends StatefulWidget {
399399
/// Defaults to EdgeInserts.all(20.0).
400400
final EdgeInsets scrollPadding;
401401

402+
/// Setting this property to true makes the cursor stop blinking and stay visible on the screen continually.
403+
/// This property is most useful for testing purposes.
404+
///
405+
/// Defaults to false, resulting in a typical blinking cursor.
406+
static bool debugDeterministicCursor = false;
407+
402408
@override
403409
EditableTextState createState() => new EditableTextState();
404410

@@ -881,7 +887,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
881887
textSpan: buildTextSpan(),
882888
value: _value,
883889
cursorColor: widget.cursorColor,
884-
showCursor: _showCursor,
890+
showCursor: EditableText.debugDeterministicCursor ? ValueNotifier<bool>(true) : _showCursor,
885891
hasFocus: _hasFocus,
886892
maxLines: widget.maxLines,
887893
selectionColor: widget.selectionColor,
@@ -1030,4 +1036,4 @@ class _Editable extends LeafRenderObjectWidget {
10301036
..cursorWidth = cursorWidth
10311037
..cursorRadius = cursorRadius;
10321038
}
1033-
}
1039+
}

0 commit comments

Comments
 (0)