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)文章
Android應(yīng)用程序的編譯流程及使用Ant編譯項目的攻略
這篇文章主要介紹了Android應(yīng)用程序的編譯流程及使用Ant編譯項目的攻略,Ant是集編譯測試部署于一體的Java自動化工具,要的朋友可以參考下2016-04-04android中圖片的三級緩存cache策略(內(nèi)存/文件/網(wǎng)絡(luò))
實現(xiàn)圖片緩存也不難,需要有相應(yīng)的cache策略。這里我采用 內(nèi)存-文件-網(wǎng)絡(luò) 三層cache機制,其中內(nèi)存緩存包括強引用緩存和軟引用緩存(SoftReference),其實網(wǎng)絡(luò)不算cache,這里姑且也把它劃到緩存的層次結(jié)構(gòu)中2013-06-06Android編程之內(nèi)存溢出解決方案(OOM)實例總結(jié)
這篇文章主要介紹了Android編程之內(nèi)存溢出解決方案(OOM),結(jié)合實例實例總結(jié)分析了Android編程過程中常見的內(nèi)存溢出情況與對應(yīng)的解決方法,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11Android AlertDialog六種創(chuàng)建方式案例詳解
這篇文章主要介紹了Android AlertDialog六種創(chuàng)建方式案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-08-08