This commit is contained in:
parent
e5e8952948
commit
dc1eefa997
@ -1150,7 +1150,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
|
|||||||
backgroundColor: _kBackgroundColor,
|
backgroundColor: _kBackgroundColor,
|
||||||
onSelectedItemChanged: (int index) {
|
onSelectedItemChanged: (int index) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedMinute = index;
|
selectedMinute = index * widget.minuteInterval;
|
||||||
widget.onTimerDurationChanged(
|
widget.onTimerDurationChanged(
|
||||||
Duration(
|
Duration(
|
||||||
hours: selectedHour ?? 0,
|
hours: selectedHour ?? 0,
|
||||||
@ -1262,7 +1262,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
|
|||||||
backgroundColor: _kBackgroundColor,
|
backgroundColor: _kBackgroundColor,
|
||||||
onSelectedItemChanged: (int index) {
|
onSelectedItemChanged: (int index) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedSecond = index;
|
selectedSecond = index * widget.secondInterval;
|
||||||
widget.onTimerDurationChanged(
|
widget.onTimerDurationChanged(
|
||||||
Duration(
|
Duration(
|
||||||
hours: selectedHour ?? 0,
|
hours: selectedHour ?? 0,
|
||||||
|
@ -198,6 +198,39 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('picker honors minuteInterval and secondInterval', (WidgetTester tester) async {
|
||||||
|
Duration duration;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
CupertinoApp(
|
||||||
|
home: SizedBox(
|
||||||
|
height: 400.0,
|
||||||
|
width: 400.0,
|
||||||
|
child: CupertinoTimerPicker(
|
||||||
|
minuteInterval: 10,
|
||||||
|
secondInterval: 15,
|
||||||
|
initialTimerDuration: const Duration(hours: 10, minutes: 40, seconds: 45),
|
||||||
|
mode: CupertinoTimerPickerMode.hms,
|
||||||
|
onTimerDurationChanged: (Duration d) {
|
||||||
|
duration = d;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.drag(find.text('40'), _kRowOffset);
|
||||||
|
await tester.pump();
|
||||||
|
await tester.drag(find.text('45'), -_kRowOffset);
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump(const Duration(milliseconds: 500));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
duration,
|
||||||
|
const Duration(hours: 10, minutes: 50, seconds: 30),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
group('Date picker', () {
|
group('Date picker', () {
|
||||||
testWidgets('mode is not null', (WidgetTester tester) async {
|
testWidgets('mode is not null', (WidgetTester tester) async {
|
||||||
expect(
|
expect(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user