• Flutter的flutter_calendar日曆的使用


    效果:

    添加依賴:

    flutter_calendar: ^0.0.1

    項目中導入

    import 'package:flutter_calendar/flutter_calendar.dart';

    例子

    import 'package:flutter/material.dart';
    import 'package:flutter_calendar/flutter_calendar.dart';
    
    main() {
      runApp(new CalendarViewApp());
    }
    
    class CalendarViewApp extends StatelessWidget {
      void handleNewDate(date) {
        print("handleNewDate ${date}");
      }
    
      @override
      Widget build(BuildContext context) {
        return new MaterialApp(
          title: 'Flutter Demo',
          theme: new ThemeData(
            primarySwatch: Colors.purple,
          ),
          home: new Scaffold(
            appBar: new AppBar(
              title: new Text('Flutter Calendar'),
            ),
            body: new Container(
              margin: new EdgeInsets.symmetric(
                horizontal: 5.0,
                vertical: 10.0,
              ),
              child: new ListView(
                shrinkWrap: true,
                children: <Widget>[
                  new Text('The Default Calendar:'),
                  new Calendar(
                    onSelectedRangeChange: (range) =>
                        print("Range is ${range.item1}, ${range.item2}"),
                    onDateSelected: (date) => handleNewDate(date),
                  ),
                  new Divider(
                    height: 50.0,
                  ),
                  new Text('The Expanded Calendar:'),
                  new Calendar(
                    onSelectedRangeChange: (range) =>
                        print("Range is ${range.item1}, ${range.item2}"),
                    isExpandable: true,
                  ),
                  new Divider(
                    height: 50.0,
                  ),
                  new Text('A Custom Weekly Calendar:'),
                  new Calendar(
                    onSelectedRangeChange: (range) =>
                        print("Range is ${range.item1}, ${range.item2}"),
                    isExpandable: true,
                    dayBuilder: (BuildContext context, DateTime day) {
                      return new InkWell(
                        onTap: () => print("OnTap ${day}"),
                        child: new Container(
                          decoration: new BoxDecoration(
                              border: new Border.all(color: Colors.black38)),
                          child: new Text(
                            day.day.toString(),
                          ),
                        ),
                      );
                    },
                  ),
                ],
              ),
            ),
          ),
        );
      }
    }
  • 相关阅读:
    ZYNQ学习系列之GPIO
    ZYNQ7000系列学习
    新的开始
    mysql-笔记 精度
    mysql-笔记 聚合函数
    QTP自动化测试-连接数据库
    mysql create/insert
    QTP自动化测试-使用数据库-配置ODBC
    QTP自动化测试-在object repository manager中定位不到控件
    QTP自动化测试-调用函数
  • 原文地址:https://www.cnblogs.com/ssjf/p/11770863.html
Copyright © 2020-2023  润新知