欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

flutter日期選擇器 flutter時間選擇器

 更新時間:2019年07月17日 08:58:07   作者:早起的年輕人  
這篇文章主要為大家詳細介紹了flutter日期選擇器,flutter時間選擇器,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了flutter日期時間選擇器的具體代碼,供大家參考,具體內(nèi)容如下

1 日期選擇器

 //設(shè)置默認顯示的日期為當前
 DateTime initialDate = DateTime.now();
 
 void showDefaultYearPicker(BuildContext context) async {
  final DateTime dateTime = await showDatePicker(
   context: context,
   //定義控件打開時默認選擇日期
   initialDate: initialDate,
   //定義控件最早可以選擇的日期
   firstDate: DateTime(2018, 1),
   //定義控件最晚可以選擇的日期
   lastDate: DateTime(2022, 1),
   builder: (BuildContext context, Widget child) {
    return Theme(
     data: CommonColors.themData,
     child: child,
    );
   },
  );
  if (dateTime != null && dateTime != initialDate) {}
 }

2 時間選擇器

 //設(shè)置顯示顯示的時間為當前
 TimeOfDay initialTime = TimeOfDay.now();
 void showDefaultDatePicker(BuildContext context) async {
  final TimeOfDay timeOfDay = await showTimePicker(
   context: context,
   initialTime: initialTime,
   builder: (BuildContext context, Widget child) {
    return Theme(
     data: CommonColors.themData,
     child: child,
    );
   },
  );
  if (timeOfDay != null && timeOfDay != initialTime) {
   setState(() {
    initialTime = timeOfDay;
   });
  }
 }

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論