@@ -357,6 +357,7 @@ class EditableText extends StatefulWidget {
357
357
@required this .controller,
358
358
@required this .focusNode,
359
359
this .readOnly = false ,
360
+ this .obscuringCharacter = '•' ,
360
361
this .obscureText = false ,
361
362
this .autocorrect = true ,
362
363
SmartDashesType smartDashesType,
@@ -413,6 +414,7 @@ class EditableText extends StatefulWidget {
413
414
this .autofillHints,
414
415
}) : assert (controller != null ),
415
416
assert (focusNode != null ),
417
+ assert (obscuringCharacter != null && obscuringCharacter.length == 1 ),
416
418
assert (obscureText != null ),
417
419
assert (autocorrect != null ),
418
420
smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType .disabled : SmartDashesType .enabled),
@@ -464,11 +466,20 @@ class EditableText extends StatefulWidget {
464
466
/// Controls whether this widget has keyboard focus.
465
467
final FocusNode focusNode;
466
468
469
+ /// {@template flutter.widgets.editableText.obscuringCharacter}
470
+ /// Character used for obscuring text if [obscureText] is true.
471
+ ///
472
+ /// Must be only a single character.
473
+ ///
474
+ /// Defaults to the character U+2022 BULLET (•).
475
+ /// {@endtemplate}
476
+ final String obscuringCharacter;
477
+
467
478
/// {@template flutter.widgets.editableText.obscureText}
468
479
/// Whether to hide the text being edited (e.g., for passwords).
469
480
///
470
481
/// When this is set to true, all the characters in the text field are
471
- /// replaced by U+2022 BULLET characters (•) .
482
+ /// replaced by [obscuringCharacter] .
472
483
///
473
484
/// Defaults to false. Cannot be null.
474
485
/// {@endtemplate}
@@ -2029,6 +2040,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
2029
2040
textDirection: _textDirection,
2030
2041
locale: widget.locale,
2031
2042
textWidthBasis: widget.textWidthBasis,
2043
+ obscuringCharacter: widget.obscuringCharacter,
2032
2044
obscureText: widget.obscureText,
2033
2045
autocorrect: widget.autocorrect,
2034
2046
smartDashesType: widget.smartDashesType,
@@ -2063,7 +2075,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
2063
2075
TextSpan buildTextSpan () {
2064
2076
if (widget.obscureText) {
2065
2077
String text = _value.text;
2066
- text = RenderEditable .obscuringCharacter * text.length;
2078
+ text = widget .obscuringCharacter * text.length;
2067
2079
final int o =
2068
2080
_obscureShowCharTicksPending > 0 ? _obscureLatestCharIndex : null ;
2069
2081
if (o != null && o >= 0 && o < text.length)
@@ -2101,6 +2113,7 @@ class _Editable extends LeafRenderObjectWidget {
2101
2113
this .textAlign,
2102
2114
@required this .textDirection,
2103
2115
this .locale,
2116
+ this .obscuringCharacter,
2104
2117
this .obscureText,
2105
2118
this .autocorrect,
2106
2119
this .smartDashesType,
@@ -2144,6 +2157,7 @@ class _Editable extends LeafRenderObjectWidget {
2144
2157
final TextAlign textAlign;
2145
2158
final TextDirection textDirection;
2146
2159
final Locale locale;
2160
+ final String obscuringCharacter;
2147
2161
final bool obscureText;
2148
2162
final TextWidthBasis textWidthBasis;
2149
2163
final bool autocorrect;
@@ -2192,6 +2206,7 @@ class _Editable extends LeafRenderObjectWidget {
2192
2206
onSelectionChanged: onSelectionChanged,
2193
2207
onCaretChanged: onCaretChanged,
2194
2208
ignorePointer: rendererIgnoresPointer,
2209
+ obscuringCharacter: obscuringCharacter,
2195
2210
obscureText: obscureText,
2196
2211
textWidthBasis: textWidthBasis,
2197
2212
cursorWidth: cursorWidth,
@@ -2234,6 +2249,7 @@ class _Editable extends LeafRenderObjectWidget {
2234
2249
..onCaretChanged = onCaretChanged
2235
2250
..ignorePointer = rendererIgnoresPointer
2236
2251
..textWidthBasis = textWidthBasis
2252
+ ..obscuringCharacter = obscuringCharacter
2237
2253
..obscureText = obscureText
2238
2254
..cursorWidth = cursorWidth
2239
2255
..cursorRadius = cursorRadius
0 commit comments