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
6e7f5803
Unverified
Commit
6e7f5803
authored
Feb 08, 2023
by
xubaolin
Committed by
GitHub
Feb 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a TextFormField bug (#120182)
* fix a TextFormField bug * review feedback
parent
1e6e6d41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
5 deletions
+50
-5
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+3
-5
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+47
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
6e7f5803
...
...
@@ -3463,11 +3463,9 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
);
}
else
{
_scrollController
.
jumpTo
(
targetOffset
.
offset
);
if
(
_value
.
selection
.
isCollapsed
)
{
renderEditable
.
showOnScreen
(
rect:
caretPadding
.
inflateRect
(
rectToReveal
),
);
}
renderEditable
.
showOnScreen
(
rect:
caretPadding
.
inflateRect
(
rectToReveal
),
);
}
});
}
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
6e7f5803
...
...
@@ -132,6 +132,52 @@ void main() {
expect
(
tester
.
testTextInput
.
setClientArgs
![
'inputAction'
],
equals
(
serializedActionName
));
}
testWidgets
(
'Text with selection can be shown on the screen when the keyboard shown'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/119628
final
ScrollController
scrollController
=
ScrollController
();
final
TextEditingController
textController
=
TextEditingController
.
fromValue
(
const
TextEditingValue
(
text:
'I love flutter'
),
);
final
Widget
widget
=
MaterialApp
(
home:
Scaffold
(
body:
SingleChildScrollView
(
controller:
scrollController
,
child:
Column
(
children:
<
Widget
>[
const
SizedBox
(
height:
1000.0
),
SizedBox
(
height:
20.0
,
child:
EditableText
(
controller:
textController
,
backgroundCursorColor:
Colors
.
grey
,
focusNode:
focusNode
,
style:
const
TextStyle
(),
cursorColor:
Colors
.
red
,
),
),
],
),
),
),
);
await
tester
.
pumpWidget
(
widget
);
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
TestWidgetsFlutterBinding
.
instance
.
window
.
viewInsetsTestValue
=
const
_TestWindowPadding
(
bottom:
500
);
addTearDown
(
TestWidgetsFlutterBinding
.
instance
.
window
.
clearViewInsetsTestValue
);
textController
.
selection
=
TextSelection
(
baseOffset:
0
,
extentOffset:
textController
.
text
.
length
,
);
await
tester
.
pump
();
// The offset of the scrollController should change immediately after window changes its metrics.
final
double
offsetAfter
=
scrollController
.
offset
;
expect
(
offsetAfter
,
isNot
(
0.0
));
});
// Related issue: https://github.com/flutter/flutter/issues/98115
testWidgets
(
'ScheduleShowCaretOnScreen with no animation when the window changes metrics'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
scrollController
=
ScrollController
();
...
...
@@ -170,6 +216,7 @@ void main() {
await
tester
.
pumpWidget
(
widget
);
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
TestWidgetsFlutterBinding
.
instance
.
window
.
viewInsetsTestValue
=
const
_TestWindowPadding
(
bottom:
500
);
addTearDown
(
TestWidgetsFlutterBinding
.
instance
.
window
.
clearViewInsetsTestValue
);
await
tester
.
pump
();
// The offset of the scrollController should change immediately after window changes its metrics.
...
...
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