【问题标题】:Flutter Web error with date picker height日期选择器高度的 Flutter Web 错误
【发布时间】:2020-05-04 00:21:45
【问题描述】:

我目前正在使用 Flutter Web 1.12.14

我正在尝试使用日期选择器,它的工作很好,但对话框显示在所有屏幕中,这样

有没有办法限制对话框的高度?

【问题讨论】:

    标签: flutter flutter-web


    【解决方案1】:

    为了限制日期选择器的大小,我们可以使用builder 参数:

          floatingActionButton: FloatingActionButton(
            child: Icon(Icons.date_range),
            onPressed: () async {
              final choice = await showDatePicker(
                  context: context,
                  firstDate: DateTime(2010),
                  lastDate: DateTime(2030),
                  initialDate: DateTime.now(),
                  builder: (BuildContext context, Widget child) {
                    return Center(
                        child: SizedBox(
                      width: 400.0,
                      height: 500.0,
                      child: child,
                    ));
                  });
              print(choice);
            },
          )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-13
      • 1970-01-01
      • 2020-02-05
      • 2020-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多