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
3c80df50
Unverified
Commit
3c80df50
authored
Nov 17, 2023
by
林洵锋
Committed by
GitHub
Nov 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NoSplash not being disposed (#138542)
Fix
https://github.com/flutter/flutter/issues/136441
parent
0135a331
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
no_splash.dart
packages/flutter/lib/src/material/no_splash.dart
+13
-0
ink_splash_test.dart
packages/flutter/test/material/ink_splash_test.dart
+64
-0
No files found.
packages/flutter/lib/src/material/no_splash.dart
View file @
3c80df50
...
...
@@ -29,6 +29,7 @@ class _NoSplashFactory extends InteractiveInkFeatureFactory {
controller:
controller
,
referenceBox:
referenceBox
,
color:
color
,
onRemoved:
onRemoved
,
);
}
}
...
...
@@ -64,4 +65,16 @@ class NoSplash extends InteractiveInkFeature {
@override
void
paintFeature
(
Canvas
canvas
,
Matrix4
transform
)
{
}
@override
void
confirm
()
{
super
.
confirm
();
dispose
();
}
@override
void
cancel
()
{
super
.
cancel
();
dispose
();
}
}
packages/flutter/test/material/ink_splash_test.dart
View file @
3c80df50
...
...
@@ -6,6 +6,39 @@ import 'package:flutter/material.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
class
Page
extends
StatefulWidget
{
const
Page
({
super
.
key
,
required
this
.
title
,
required
this
.
onDispose
,
});
final
String
title
;
final
void
Function
()?
onDispose
;
@override
State
<
Page
>
createState
()
=>
_PageState
();
}
class
_PageState
extends
State
<
Page
>
{
@override
void
dispose
()
{
widget
.
onDispose
?.
call
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Center
(
child:
FilledButton
(
onPressed:
()
{},
child:
Text
(
widget
.
title
),
),
);
}
}
void
main
(
)
{
// Regression test for https://github.com/flutter/flutter/issues/21506.
testWidgetsWithLeakTracking
(
'InkSplash receives textDirection'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -66,4 +99,35 @@ void main() {
await
tester
.
pumpAndSettle
();
}
});
// Regression test for https://github.com/flutter/flutter/issues/136441.
testWidgetsWithLeakTracking
(
'PageView item can dispose when widget with NoSplash.splashFactory is tapped'
,
(
WidgetTester
tester
)
async
{
final
PageController
controller
=
PageController
();
final
List
<
int
>
disposedPageIndexes
=
<
int
>[];
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
splashFactory:
NoSplash
.
splashFactory
),
home:
Scaffold
(
body:
PageView
.
builder
(
controller:
controller
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Page
(
title:
'Page
$index
'
,
onDispose:
()
{
disposedPageIndexes
.
add
(
index
);
},
);
},
itemCount:
3
,
),
),
));
controller
.
jumpToPage
(
1
);
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'Page 1'
));
await
tester
.
pumpAndSettle
();
controller
.
jumpToPage
(
0
);
await
tester
.
pumpAndSettle
();
expect
(
disposedPageIndexes
,
<
int
>[
0
,
1
]);
controller
.
dispose
();
});
}
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