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
680a8192
Unverified
Commit
680a8192
authored
May 25, 2022
by
Jonah Williams
Committed by
GitHub
May 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[framework] ensure ink sparkle is disposed (#104569)
parent
09987dc0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
ink_sparkle.dart
packages/flutter/lib/src/material/ink_sparkle.dart
+10
-1
material.dart
packages/flutter/lib/src/material/material.dart
+6
-0
ink_sparkle_test.dart
packages/flutter/test/material/ink_sparkle_test.dart
+11
-5
No files found.
packages/flutter/lib/src/material/ink_sparkle.dart
View file @
680a8192
...
...
@@ -135,7 +135,9 @@ class InkSparkle extends InteractiveInkFeature {
_animationController
=
AnimationController
(
duration:
_animationDuration
,
vsync:
controller
.
vsync
,
)..
addListener
(
controller
.
markNeedsPaint
)..
forward
();
)..
addListener
(
controller
.
markNeedsPaint
)
..
addStatusListener
(
_handleStatusChanged
)
..
forward
();
_radiusScale
=
TweenSequence
<
double
>(
<
TweenSequenceItem
<
double
>>[
...
...
@@ -209,6 +211,11 @@ class InkSparkle extends InteractiveInkFeature {
_turbulenceSeed
=
turbulenceSeed
??
math
.
Random
().
nextDouble
()
*
1000.0
;
}
void
_handleStatusChanged
(
AnimationStatus
status
)
{
if
(
status
==
AnimationStatus
.
completed
)
dispose
();
}
static
const
Duration
_animationDuration
=
Duration
(
milliseconds:
617
);
static
const
double
_targetRadiusMultiplier
=
2.3
;
static
const
double
_rotateRight
=
math
.
pi
*
0.0078125
;
...
...
@@ -259,6 +266,8 @@ class InkSparkle extends InteractiveInkFeature {
@override
void
paintFeature
(
Canvas
canvas
,
Matrix4
transform
)
{
assert
(
_animationController
.
isAnimating
);
// InkSparkle can only paint if its shader has been compiled.
if
(
_InkSparkleFactory
.
_shaderManager
==
null
)
{
// Skipping paintFeature because the shader it relies on is not ready to
...
...
packages/flutter/lib/src/material/material.dart
View file @
680a8192
...
...
@@ -557,6 +557,12 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
bool
absorbHitTest
;
@visibleForTesting
List
<
InkFeature
>?
get
debugInkFeatures
{
if
(
kDebugMode
)
return
_inkFeatures
;
return
null
;
}
List
<
InkFeature
>?
_inkFeatures
;
@override
...
...
packages/flutter/test/material/ink_sparkle_test.dart
View file @
680a8192
...
...
@@ -48,16 +48,23 @@ void main() {
final
Finder
buttonFinder
=
find
.
text
(
'Sparkle!'
);
await
tester
.
tap
(
buttonFinder
);
await
tester
.
pump
();
await
tester
.
pump
AndSettle
(
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
)
);
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
buttonFinder
))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawRect
,
1
));
// ignore: avoid_dynamic_calls
expect
((
material
as
dynamic
).
debugInkFeatures
,
hasLength
(
1
));
await
tester
.
pumpAndSettle
();
// ink feature is disposed.
// ignore: avoid_dynamic_calls
expect
((
material
as
dynamic
).
debugInkFeatures
,
isEmpty
);
},
skip:
kIsWeb
,
// [intended] SPIR-V shaders are not yet supported for web.
);
testWidgets
(
'InkSparkle default splashFactory paints with drawPaint when unbounded'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'InkSparkle default splashFactory paints with drawPaint when unbounded'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Center
(
...
...
@@ -72,10 +79,9 @@ void main() {
final
Finder
buttonFinder
=
find
.
text
(
'Sparkle!'
);
await
tester
.
tap
(
buttonFinder
);
await
tester
.
pump
();
await
tester
.
pump
AndSettle
(
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
)
);
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
buttonFinder
))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawPaint
,
1
));
},
skip:
kIsWeb
,
// [intended] SPIR-V shaders are not yet supported for web.
...
...
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