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
05759325
Unverified
Commit
05759325
authored
Apr 14, 2022
by
Bruno Leroux
Committed by
GitHub
Apr 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix InkWell highlight and splash sometimes persists (#100880)
parent
cb968c5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
4 deletions
+92
-4
ink_well.dart
packages/flutter/lib/src/material/ink_well.dart
+6
-4
ink_well_test.dart
packages/flutter/test/material/ink_well_test.dart
+86
-0
No files found.
packages/flutter/lib/src/material/ink_well.dart
View file @
05759325
...
...
@@ -769,12 +769,12 @@ class _InkResponseState extends State<_InkResponseStateWidget>
bool
get
_anyChildInkResponsePressed
=>
_activeChildren
.
isNotEmpty
;
void
_simulateTap
([
Intent
?
intent
])
{
_startSplash
(
context:
context
);
_start
New
Splash
(
context:
context
);
_handleTap
();
}
void
_simulateLongPress
()
{
_startSplash
(
context:
context
);
_start
New
Splash
(
context:
context
);
_handleLongPress
();
}
...
...
@@ -966,7 +966,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
void
_handleTapDown
(
TapDownDetails
details
)
{
if
(
_anyChildInkResponsePressed
)
return
;
_startSplash
(
details:
details
);
_start
New
Splash
(
details:
details
);
widget
.
onTapDown
?.
call
(
details
);
}
...
...
@@ -974,7 +974,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
widget
.
onTapUp
?.
call
(
details
);
}
void
_startSplash
({
TapDownDetails
?
details
,
BuildContext
?
context
})
{
void
_start
New
Splash
({
TapDownDetails
?
details
,
BuildContext
?
context
})
{
assert
(
details
!=
null
||
context
!=
null
);
final
Offset
globalPosition
;
...
...
@@ -988,6 +988,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
final
InteractiveInkFeature
splash
=
_createInkFeature
(
globalPosition
);
_splashes
??=
HashSet
<
InteractiveInkFeature
>();
_splashes
!.
add
(
splash
);
_currentSplash
?.
cancel
();
_currentSplash
=
splash
;
updateKeepAlive
();
updateHighlight
(
_HighlightType
.
pressed
,
value:
true
);
...
...
@@ -1014,6 +1015,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
void
_handleDoubleTap
()
{
_currentSplash
?.
confirm
();
_currentSplash
=
null
;
updateHighlight
(
_HighlightType
.
pressed
,
value:
false
);
widget
.
onDoubleTap
?.
call
();
}
...
...
packages/flutter/test/material/ink_well_test.dart
View file @
05759325
...
...
@@ -1424,4 +1424,90 @@ void main() {
textDirection:
TextDirection
.
ltr
,
));
});
testWidgets
(
'InkWell highlight should not survive after [onTapDown, onDoubleTap] sequence'
,
(
WidgetTester
tester
)
async
{
final
List
<
String
>
log
=
<
String
>[];
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
InkWell
(
onTap:
()
{
log
.
add
(
'tap'
);
},
onDoubleTap:
()
{
log
.
add
(
'double-tap'
);
},
onTapDown:
(
TapDownDetails
details
)
{
log
.
add
(
'tap-down'
);
},
onTapCancel:
()
{
log
.
add
(
'tap-cancel'
);
},
),
),
),
));
final
Offset
taplocation
=
tester
.
getRect
(
find
.
byType
(
InkWell
)).
center
;
final
TestGesture
gesture
=
await
tester
.
startGesture
(
taplocation
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
log
,
equals
(<
String
>[
'tap-down'
]));
await
gesture
.
up
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
await
tester
.
tap
(
find
.
byType
(
InkWell
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
log
,
equals
(<
String
>[
'tap-down'
,
'double-tap'
]));
await
tester
.
pumpAndSettle
();
final
RenderObject
inkFeatures
=
tester
.
allRenderObjects
.
firstWhere
((
RenderObject
object
)
=>
object
.
runtimeType
.
toString
()
==
'_RenderInkFeatures'
);
expect
(
inkFeatures
,
paintsExactlyCountTimes
(
#drawRect
,
0
));
});
testWidgets
(
'InkWell splash should not survive after [onTapDown, onTapDown, onTapCancel, onDoubleTap] sequence'
,
(
WidgetTester
tester
)
async
{
final
List
<
String
>
log
=
<
String
>[];
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Center
(
child:
InkWell
(
onTap:
()
{
log
.
add
(
'tap'
);
},
onDoubleTap:
()
{
log
.
add
(
'double-tap'
);
},
onTapDown:
(
TapDownDetails
details
)
{
log
.
add
(
'tap-down'
);
},
onTapCancel:
()
{
log
.
add
(
'tap-cancel'
);
},
),
),
),
));
final
Offset
tapLocation
=
tester
.
getRect
(
find
.
byType
(
InkWell
)).
center
;
final
TestGesture
gesture1
=
await
tester
.
startGesture
(
tapLocation
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
log
,
equals
(<
String
>[
'tap-down'
]));
await
gesture1
.
up
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
final
TestGesture
gesture2
=
await
tester
.
startGesture
(
tapLocation
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
log
,
equals
(<
String
>[
'tap-down'
,
'tap-down'
]));
await
gesture2
.
up
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
log
,
equals
(<
String
>[
'tap-down'
,
'tap-down'
,
'tap-cancel'
,
'double-tap'
]));
await
tester
.
pumpAndSettle
();
final
RenderObject
inkFeatures
=
tester
.
allRenderObjects
.
firstWhere
((
RenderObject
object
)
=>
object
.
runtimeType
.
toString
()
==
'_RenderInkFeatures'
);
expect
(
inkFeatures
,
paintsExactlyCountTimes
(
#drawCircle
,
0
));
});
}
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