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
0aec2c3d
Unverified
Commit
0aec2c3d
authored
Dec 01, 2020
by
tgucio
Committed by
GitHub
Dec 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restart EditableText cursor timer when it moves (#70787)
parent
720f366f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
0 deletions
+81
-0
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+6
-0
editable_text_cursor_test.dart
packages/flutter/test/widgets/editable_text_cursor_test.dart
+75
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
0aec2c3d
...
...
@@ -2089,6 +2089,12 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
));
}
}
// To keep the cursor from blinking while it moves, restart the timer here.
if
(
_cursorTimer
!=
null
)
{
_stopCursorTimer
(
resetCharTicks:
false
);
_startCursorTimer
();
}
}
bool
_textChangedSinceLastCaretUpdate
=
false
;
...
...
packages/flutter/test/widgets/editable_text_cursor_test.dart
View file @
0aec2c3d
...
...
@@ -323,6 +323,81 @@ void main() {
EditableText
.
debugDeterministicCursor
=
false
;
});
testWidgets
(
'Cursor animation restarts when it is moved using keys on desktop'
,
(
WidgetTester
tester
)
async
{
const
String
testText
=
'Some text long enough to move the cursor around'
;
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
final
Widget
widget
=
MaterialApp
(
home:
EditableText
(
controller:
controller
,
focusNode:
FocusNode
(),
style:
const
TextStyle
(
fontSize:
20.0
),
maxLines:
1
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
cursorOpacityAnimates:
false
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
textAlign:
TextAlign
.
left
,
),
);
await
tester
.
pumpWidget
(
widget
);
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
pump
();
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
)));
// 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
.
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:
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
.
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:
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
));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
macOS
}));
testWidgets
(
'Cursor does not show when showCursor set to false'
,
(
WidgetTester
tester
)
async
{
const
Widget
widget
=
MaterialApp
(
home:
Material
(
...
...
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