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
6157c0e8
Unverified
Commit
6157c0e8
authored
Sep 20, 2022
by
Callum Moffat
Committed by
GitHub
Sep 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove controller listener on CupertinoPicker dispose (#111977)
parent
30ebb0d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
picker.dart
packages/flutter/lib/src/cupertino/picker.dart
+6
-0
picker_test.dart
packages/flutter/test/cupertino/picker_test.dart
+38
-0
No files found.
packages/flutter/lib/src/cupertino/picker.dart
View file @
6157c0e8
...
...
@@ -513,4 +513,10 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox {
}
node
.
updateWith
(
config:
config
);
}
@override
void
dispose
()
{
super
.
dispose
();
controller
.
removeListener
(
_handleScrollUpdate
);
}
}
packages/flutter/test/cupertino/picker_test.dart
View file @
6157c0e8
...
...
@@ -11,6 +11,12 @@ import 'package:flutter_test/flutter_test.dart';
import
'../rendering/mock_canvas.dart'
;
class
SpyFixedExtentScrollController
extends
FixedExtentScrollController
{
/// Override for test visibility only.
@override
bool
get
hasListeners
=>
super
.
hasListeners
;
}
void
main
(
)
{
testWidgets
(
'Picker respects theme styling'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
...
...
@@ -490,4 +496,36 @@ void main() {
expect
(
borderRadius
,
isA
<
BorderRadiusDirectional
>());
});
});
testWidgets
(
'Scroll controller is detached upon dispose'
,
(
WidgetTester
tester
)
async
{
final
SpyFixedExtentScrollController
controller
=
SpyFixedExtentScrollController
();
expect
(
controller
.
hasListeners
,
false
);
expect
(
controller
.
positions
.
length
,
0
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Align
(
alignment:
Alignment
.
topLeft
,
child:
Center
(
child:
CupertinoPicker
(
scrollController:
controller
,
itemExtent:
50.0
,
onSelectedItemChanged:
(
_
)
{
},
children:
List
<
Widget
>.
generate
(
3
,
(
int
index
)
{
return
SizedBox
(
width:
300.0
,
child:
Text
(
index
.
toString
()),
);
}),
),
),
),
));
expect
(
controller
.
hasListeners
,
true
);
expect
(
controller
.
positions
.
length
,
1
);
await
tester
.
pumpWidget
(
const
SizedBox
.
expand
());
expect
(
controller
.
hasListeners
,
false
);
expect
(
controller
.
positions
.
length
,
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