Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7d539043
Unverified
Commit
7d539043
authored
Nov 02, 2020
by
LongCatIsLooong
Committed by
GitHub
Nov 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dont mess with user supplied list (#69594)
parent
88809aa2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
7 deletions
+36
-7
text_field.dart
packages/flutter/lib/src/cupertino/text_field.dart
+4
-4
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+4
-3
text_field_test.dart
packages/flutter/test/cupertino/text_field_test.dart
+12
-0
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+16
-0
No files found.
packages/flutter/lib/src/cupertino/text_field.dart
View file @
7d539043
...
...
@@ -878,13 +878,13 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
super
.
build
(
context
);
// See AutomaticKeepAliveClientMixin.
assert
(
debugCheckHasDirectionality
(
context
));
final
TextEditingController
controller
=
_effectiveController
;
final
List
<
TextInputFormatter
>
formatters
=
widget
.
inputFormatters
??
<
TextInputFormatter
>[];
final
TextSelectionControls
textSelectionControls
=
widget
.
selectionControls
??
cupertinoTextSelectionControls
;
final
bool
enabled
=
widget
.
enabled
??
true
;
final
Offset
cursorOffset
=
Offset
(
_iOSHorizontalCursorOffsetPixels
/
MediaQuery
.
of
(
context
).
devicePixelRatio
,
0
);
if
(
widget
.
maxLength
!=
null
&&
widget
.
maxLengthEnforced
)
{
formatters
.
add
(
LengthLimitingTextInputFormatter
(
widget
.
maxLength
));
}
final
List
<
TextInputFormatter
>
formatters
=
<
TextInputFormatter
>[
...?
widget
.
inputFormatters
,
if
(
widget
.
maxLength
!=
null
&&
widget
.
maxLengthEnforced
)
LengthLimitingTextInputFormatter
(
widget
.
maxLength
)
];
final
CupertinoThemeData
themeData
=
CupertinoTheme
.
of
(
context
);
final
TextStyle
?
resolvedStyle
=
widget
.
style
?.
copyWith
(
...
...
packages/flutter/lib/src/material/text_field.dart
View file @
7d539043
...
...
@@ -1261,9 +1261,10 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
final
Brightness
keyboardAppearance
=
widget
.
keyboardAppearance
??
theme
.
primaryColorBrightness
;
final
TextEditingController
controller
=
_effectiveController
;
final
FocusNode
focusNode
=
_effectiveFocusNode
;
final
List
<
TextInputFormatter
>
formatters
=
widget
.
inputFormatters
??
<
TextInputFormatter
>[];
if
(
widget
.
maxLength
!=
null
&&
widget
.
maxLengthEnforced
)
formatters
.
add
(
LengthLimitingTextInputFormatter
(
widget
.
maxLength
));
final
List
<
TextInputFormatter
>
formatters
=
<
TextInputFormatter
>[
...?
widget
.
inputFormatters
,
if
(
widget
.
maxLength
!=
null
&&
widget
.
maxLengthEnforced
)
LengthLimitingTextInputFormatter
(
widget
.
maxLength
)
];
TextSelectionControls
?
textSelectionControls
=
widget
.
selectionControls
;
final
bool
paintCursorAboveText
;
...
...
packages/flutter/test/cupertino/text_field_test.dart
View file @
7d539043
...
...
@@ -4289,4 +4289,16 @@ void main() {
final
EditableText
widget
=
tester
.
widget
(
find
.
byType
(
EditableText
));
expect
(
widget
.
selectionControls
,
equals
(
selectionControl
));
});
testWidgets
(
'Do not add LengthLimiting formatter to the user supplied list'
,
(
WidgetTester
tester
)
async
{
final
List
<
TextInputFormatter
>
formatters
=
<
TextInputFormatter
>[];
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoTextField
(
maxLength:
5
,
inputFormatters:
formatters
),
)
);
expect
(
formatters
.
isEmpty
,
isTrue
);
});
}
packages/flutter/test/material/text_field_test.dart
View file @
7d539043
...
...
@@ -3344,6 +3344,22 @@ void main() {
expect
(
textController
.
text
,
'145623'
);
});
testWidgets
(
'Do not add LengthLimiting formatter to the user supplied list'
,
(
WidgetTester
tester
)
async
{
final
List
<
TextInputFormatter
>
formatters
=
<
TextInputFormatter
>[];
await
tester
.
pumpWidget
(
overlay
(
child:
TextField
(
decoration:
null
,
maxLength:
5
,
inputFormatters:
formatters
,
),
),
);
expect
(
formatters
.
isEmpty
,
isTrue
);
});
testWidgets
(
'Text field scrolls the caret into view'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment