CupertinoDatePicker在滚动分钟时禁用小时更改

时间:2019-07-19 11:53:20

标签: flutter dart flutter-cupertino

滚动小时时如何禁用更改分钟?

click gif

方法

  Widget time() {
    return CupertinoTimerPicker(
      mode: CupertinoTimerPickerMode.hm,
      minuteInterval: 1,
      secondInterval: 1,
      initialTimerDuration: initialtimer,
      onTimerDurationChanged: (Duration changedtimer) {
        setState(() {
          initialtimer = changedtimer;
        });
      },
    );
  }

小部件上的通话时间()

        child: MaterialButton(
          child: Align(
            alignment: Alignment.centerLeft,

如果初始计时器值0显示提示(那是错误的代码吗?)

            child: initialtimer.inHours == 0 &&  initialtimer.inMinutes == 0
                ? Text('Hours : Minutes')
                : Text(
                    "${initialtimer.inHours} : ${initialtimer.inMinutes}"),
          ),

onPressed()

          onPressed: () {
            showModalBottomSheet(
                context: context,
                builder: (BuildContext builder) {
                  return Container(
                      height: MediaQuery.of(context)
                              .copyWith()
                              .size
                              .height /
                          3,
                      child: time());
                });
          },
        ),

0 个答案:

没有答案