@@ -1990,6 +1990,10 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
1990
1990
late double totalWidth;
1991
1991
late double pickerColumnWidth;
1992
1992
1993
+ FixedExtentScrollController ? _hourScrollController;
1994
+ FixedExtentScrollController ? _minuteScrollController;
1995
+ FixedExtentScrollController ? _secondScrollController;
1996
+
1993
1997
@override
1994
1998
void initState () {
1995
1999
super .initState ();
@@ -2019,6 +2023,10 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
2019
2023
void dispose () {
2020
2024
PaintingBinding .instance.systemFonts.removeListener (_handleSystemFontsChange);
2021
2025
textPainter.dispose ();
2026
+
2027
+ _hourScrollController? .dispose ();
2028
+ _minuteScrollController? .dispose ();
2029
+ _secondScrollController? .dispose ();
2022
2030
super .dispose ();
2023
2031
}
2024
2032
@@ -2164,8 +2172,11 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
2164
2172
}
2165
2173
2166
2174
Widget _buildHourPicker (EdgeInsetsDirectional additionalPadding, Widget selectionOverlay) {
2175
+ _hourScrollController ?? = FixedExtentScrollController (
2176
+ initialItem: selectedHour!
2177
+ );
2167
2178
return CupertinoPicker (
2168
- scrollController: FixedExtentScrollController (initialItem : selectedHour ! ) ,
2179
+ scrollController: _hourScrollController ,
2169
2180
magnification: _kMagnification,
2170
2181
offAxisFraction: _calculateOffAxisFraction (additionalPadding.start, 0 ),
2171
2182
itemExtent: widget.itemExtent,
@@ -2223,10 +2234,11 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
2223
2234
}
2224
2235
2225
2236
Widget _buildMinutePicker (EdgeInsetsDirectional additionalPadding, Widget selectionOverlay) {
2237
+ _minuteScrollController ?? = FixedExtentScrollController (
2238
+ initialItem: selectedMinute ~ / widget.minuteInterval,
2239
+ );
2226
2240
return CupertinoPicker (
2227
- scrollController: FixedExtentScrollController (
2228
- initialItem: selectedMinute ~ / widget.minuteInterval,
2229
- ),
2241
+ scrollController: _minuteScrollController,
2230
2242
magnification: _kMagnification,
2231
2243
offAxisFraction: _calculateOffAxisFraction (
2232
2244
additionalPadding.start,
@@ -2289,10 +2301,11 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
2289
2301
}
2290
2302
2291
2303
Widget _buildSecondPicker (EdgeInsetsDirectional additionalPadding, Widget selectionOverlay) {
2304
+ _secondScrollController ?? = FixedExtentScrollController (
2305
+ initialItem: selectedSecond! ~ / widget.secondInterval,
2306
+ );
2292
2307
return CupertinoPicker (
2293
- scrollController: FixedExtentScrollController (
2294
- initialItem: selectedSecond! ~ / widget.secondInterval,
2295
- ),
2308
+ scrollController: _secondScrollController,
2296
2309
magnification: _kMagnification,
2297
2310
offAxisFraction: _calculateOffAxisFraction (
2298
2311
additionalPadding.start,
0 commit comments