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
cef737c4
Unverified
Commit
cef737c4
authored
Sep 13, 2023
by
Polina Cherkasova
Committed by
GitHub
Sep 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_YearPicker should dispose ScrollController and MaterialSatesController. (#134393)
parent
7d0c9b72
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
calendar_date_picker.dart
packages/flutter/lib/src/material/calendar_date_picker.dart
+12
-3
scroll_controller.dart
packages/flutter/lib/src/widgets/scroll_controller.dart
+0
-2
calendar_date_picker_test.dart
...ages/flutter/test/material/calendar_date_picker_test.dart
+3
-2
No files found.
packages/flutter/lib/src/material/calendar_date_picker.dart
View file @
cef737c4
...
...
@@ -1147,7 +1147,8 @@ class YearPicker extends StatefulWidget {
}
class
_YearPickerState
extends
State
<
YearPicker
>
{
late
ScrollController
_scrollController
;
ScrollController
?
_scrollController
;
final
MaterialStatesController
_statesController
=
MaterialStatesController
();
// The approximate number of years necessary to fill the available space.
static
const
int
minYears
=
18
;
...
...
@@ -1158,11 +1159,18 @@ class _YearPickerState extends State<YearPicker> {
_scrollController
=
ScrollController
(
initialScrollOffset:
_scrollOffsetForYear
(
widget
.
selectedDate
??
widget
.
firstDate
));
}
@override
void
dispose
()
{
_scrollController
?.
dispose
();
_statesController
.
dispose
();
super
.
dispose
();
}
@override
void
didUpdateWidget
(
YearPicker
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
if
(
widget
.
selectedDate
!=
oldWidget
.
selectedDate
&&
widget
.
selectedDate
!=
null
)
{
_scrollController
.
jumpTo
(
_scrollOffsetForYear
(
widget
.
selectedDate
!));
_scrollController
!
.
jumpTo
(
_scrollOffsetForYear
(
widget
.
selectedDate
!));
}
}
...
...
@@ -1255,10 +1263,11 @@ class _YearPickerState extends State<YearPicker> {
assert
(
date
.
year
==
widget
.
lastDate
.
year
);
date
=
DateTime
(
year
,
widget
.
lastDate
.
month
);
}
_statesController
.
value
=
states
;
yearItem
=
InkWell
(
key:
ValueKey
<
int
>(
year
),
onTap:
()
=>
widget
.
onChanged
(
date
),
statesController:
MaterialStatesController
(
states
)
,
statesController:
_statesController
,
overlayColor:
overlayColor
,
child:
yearItem
,
);
...
...
packages/flutter/lib/src/widgets/scroll_controller.dart
View file @
cef737c4
...
...
@@ -57,8 +57,6 @@ typedef ScrollControllerCallback = void Function(ScrollPosition position);
/// listen to scrolling occur without using a [ScrollController].
class
ScrollController
extends
ChangeNotifier
{
/// Creates a controller for a scrollable widget.
///
/// The values of `initialScrollOffset` and `keepScrollOffset` must not be null.
ScrollController
({
double
initialScrollOffset
=
0.0
,
this
.
keepScrollOffset
=
true
,
...
...
packages/flutter/test/material/calendar_date_picker_test.dart
View file @
cef737c4
...
...
@@ -5,6 +5,7 @@
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'feedback_tester.dart'
;
...
...
@@ -211,7 +212,7 @@ void main() {
expect
(
selectedDate
,
equals
(
DateTime
(
2018
,
DateTime
.
january
,
4
)));
});
testWidgets
(
'Changing year for february 29th'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Changing year for february 29th'
,
(
WidgetTester
tester
)
async
{
DateTime
?
selectedDate
;
await
tester
.
pumpWidget
(
calendarDatePicker
(
initialDate:
DateTime
(
2020
,
DateTime
.
february
,
29
),
...
...
@@ -230,7 +231,7 @@ void main() {
expect
(
selectedDate
,
equals
(
DateTime
(
2020
,
DateTime
.
february
,
28
)));
});
testWidgets
(
'Changing year does not change the month'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Changing year does not change the month'
,
(
WidgetTester
tester
)
async
{
DateTime
?
displayedMonth
;
await
tester
.
pumpWidget
(
calendarDatePicker
(
initialDate:
DateTime
(
2016
,
DateTime
.
january
,
15
),
...
...
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