• 允许不支持空安全的插件--no-sound-null-safety
    • 日期选择框-第三方

      1. //28行格式化日期需安装date_format
      2. DateTime _date=DateTime.now();
      3. _showDatePicker2(){
      4. DatePicker.showDatePicker(context,
      5. showTitleActions: true,
      6. minTime: DateTime(1999,1,1),
      7. maxTime:DateTime(2050,12,31),
      8. onChanged: (result){//更改时触发
      9. setState(() {
      10. this._date=result;
      11. print('onChanged');
      12. });
      13. },onConfirm: (result){//确认后触发
      14. setState(() {
      15. this._date=result;
      16. print('onConfirm');
      17. });
      18. },
      19. currentTime: _date,//默认时间
      20. locale: LocaleType.zh,
      21. );
      22. }
      23. ...
      24. InkWell(
      25. child: Row(
      26. mainAxisAlignment: MainAxisAlignment.center,
      27. children: [
      28. Text("${formatDate(_date, [yyyy,'年',mm,'月',dd,'日'])}"),
      29. Icon(Icons.arrow_drop_down),
      30. ],
      31. ),
      32. onTap: _showDatePicker2,
      33. ),
    • 时间选择框-第三方

      1. //24行格式化日期需安装date_format
      2. DateTime _date=DateTime.now();
      3. _showTimePicker2(){
      4. DatePicker.showTimePicker(context,
      5. showTitleActions: true,
      6. onChanged: (result){//更改时触发
      7. setState(() {
      8. this._date=result;
      9. });
      10. },onConfirm: (result){//确认后触发
      11. setState(() {
      12. this._date=result;
      13. });
      14. },
      15. currentTime: _date,//默认时间
      16. locale: LocaleType.zh,
      17. );
      18. }
      19. ...
      20. InkWell(
      21. child: Row(
      22. mainAxisAlignment: MainAxisAlignment.center,
      23. children: [
      24. Text("${formatDate(_date, [HH, ':', nn])}"),
      25. Icon(Icons.arrow_drop_down),
      26. ],
      27. ),
      28. onTap: _showTimePicker2,
      29. ),
    • 第三方时间控件datetime_picker的坑

      1. //color: theme.backgroundColor ?? Colors.white,
      2. flutter_datetime_picker.dart 文件中的改为
      3. color: theme.headerColor ?? theme.backgroundColor,
    • 轮播图、启动引导图

      1. import 'package:flutter_swiper/flutter_swiper.dart';
      2. ...
      3. 安装flutter_swiper: ^1.1.6
      4. ...
      5. List<Map> imgList=[
      6. {
      7. 'url':"https://www.itying.com/images/flutter/1.png",
      8. },
      9. {
      10. 'url':"https://www.itying.com/images/flutter/2.png",
      11. },
      12. {
      13. 'url':"https://www.itying.com/images/flutter/3.png",
      14. }
      15. ];
      16. ...
      17. Swiper(
      18. itemCount: 3,
      19. itemBuilder: (BuildContext content,int index){
      20. return new Image.network(
      21. imgList[index]['url'],
      22. fit:BoxFit.fill,
      23. );
      24. },
      25. pagination: new SwiperPagination(),
      26. controller: new SwiperController(),
      27. );
      28. 用于该插件暂未支持空安全,
      29. 运行需要执行 flutter run --no-sound-null-safety
      30. 生成apk需执行 flutter build apk --no-sound-null-safety
      31. 其他该插件相关信息:
      32. https://github.com/best-flutter/flutter_swiper/blob/master/README-ZH.md