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
2dc8bb18
Unverified
Commit
2dc8bb18
authored
Jul 19, 2022
by
Swain
Committed by
GitHub
Jul 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the cursor no longer blinking when move, as same as the effect of iOS platform. (#107221)
parent
2327bb7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+5
-0
editable_text_cursor_test.dart
packages/flutter/test/widgets/editable_text_cursor_test.dart
+67
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
2dc8bb18
...
...
@@ -2184,6 +2184,9 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
_floatingCursorResetController
!.
stop
();
_onFloatingCursorResetTick
();
}
// Stop cursor blinking and making it visible.
_stopCursorBlink
(
resetCharTicks:
false
);
_cursorBlinkOpacityController
.
value
=
1.0
;
// We want to send in points that are centered around a (0,0) origin, so
// we cache the position.
_pointOffsetOrigin
=
point
.
offset
;
...
...
@@ -2204,6 +2207,8 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
renderEditable
.
setFloatingCursor
(
point
.
state
,
_lastBoundedOffset
!,
_lastTextPosition
!);
break
;
case
FloatingCursorDragState
.
End
:
// Resume cursor blinking.
_startCursorBlink
();
// We skip animation if no update has happened.
if
(
_lastTextPosition
!=
null
&&
_lastBoundedOffset
!=
null
)
{
_floatingCursorResetController
!.
value
=
0.0
;
...
...
packages/flutter/test/widgets/editable_text_cursor_test.dart
View file @
2dc8bb18
...
...
@@ -701,6 +701,73 @@ void main() {
expect
(
tester
.
takeException
(),
null
);
});
testWidgets
(
"Drag the floating cursor, it won't blink."
,
(
WidgetTester
tester
)
async
{
const
String
text
=
'hello world this is fun and cool and awesome!'
;
controller
.
text
=
text
;
final
FocusNode
focusNode
=
FocusNode
();
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
FocusScope
(
node:
focusScopeNode
,
autofocus:
true
,
child:
EditableText
(
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
),
),
),
),
);
final
EditableTextState
editableText
=
tester
.
state
(
find
.
byType
(
EditableText
));
// Check that the cursor visibility toggles after each blink interval.
// Or if it's not blinking at all, it stays on.
Future
<
void
>
checkCursorBlinking
({
bool
isBlinking
=
true
})
async
{
bool
initialShowCursor
=
true
;
if
(
isBlinking
)
{
initialShowCursor
=
editableText
.
cursorCurrentlyVisible
;
}
await
tester
.
pump
(
editableText
.
cursorBlinkInterval
);
expect
(
editableText
.
cursorCurrentlyVisible
,
equals
(
isBlinking
?
!
initialShowCursor
:
initialShowCursor
));
await
tester
.
pump
(
editableText
.
cursorBlinkInterval
);
expect
(
editableText
.
cursorCurrentlyVisible
,
equals
(
initialShowCursor
));
await
tester
.
pump
(
editableText
.
cursorBlinkInterval
~/
10
);
expect
(
editableText
.
cursorCurrentlyVisible
,
equals
(
initialShowCursor
));
await
tester
.
pump
(
editableText
.
cursorBlinkInterval
);
expect
(
editableText
.
cursorCurrentlyVisible
,
equals
(
isBlinking
?
!
initialShowCursor
:
initialShowCursor
));
await
tester
.
pump
(
editableText
.
cursorBlinkInterval
);
expect
(
editableText
.
cursorCurrentlyVisible
,
equals
(
initialShowCursor
));
}
final
Offset
textfieldStart
=
tester
.
getTopLeft
(
find
.
byType
(
EditableText
));
await
tester
.
tapAt
(
textfieldStart
+
const
Offset
(
50.0
,
9.0
));
await
tester
.
pumpAndSettle
();
// Before dragging, the cursor should blink.
await
checkCursorBlinking
();
final
EditableTextState
editableTextState
=
tester
.
firstState
(
find
.
byType
(
EditableText
));
editableTextState
.
updateFloatingCursor
(
RawFloatingCursorPoint
(
state:
FloatingCursorDragState
.
Start
));
// When drag cursor, the cursor shouldn't blink.
await
checkCursorBlinking
(
isBlinking:
false
);
editableTextState
.
updateFloatingCursor
(
RawFloatingCursorPoint
(
state:
FloatingCursorDragState
.
End
));
await
tester
.
pumpAndSettle
();
// After dragging, the cursor should blink.
await
checkCursorBlinking
();
});
// Regression test for https://github.com/flutter/flutter/pull/30475.
testWidgets
(
'Trying to select with the floating cursor does not crash'
,
(
WidgetTester
tester
)
async
{
const
String
text
=
'hello world this is fun and cool and awesome!'
;
...
...
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