flutter日期時間選擇器的代碼怎么寫,針對這個問題,這篇文章詳細介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

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; }); } }
關(guān)于flutter日期時間選擇器的代碼怎么寫問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。
文章題目:flutter日期時間選擇器的代碼怎么寫-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://www.chinadenli.net/article26/dcsecg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、云服務(wù)器、Google、定制網(wǎng)站、網(wǎng)站策劃、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容