• Stars
    star
    112
  • Rank 302,576 (Top 7 %)
  • Language
    Dart
  • License
    Other
  • Created over 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Date component developed with Flutter, plans to support display, swipe left and right, add date mark, radio, display week, etc.

mini_calendar

GitHub code size in bytes

Date component developed with Flutter, plans to support display, swipe left and right, add date mark, radio, display week, etc.

使用Flutter开发的日期组件,计划支持显示,左右滑动,添加日期标记,单选,显示星期等功能。

主要想实现的内容

功能设计

使用

引入库

dependencies:
  mini_calendar: ^2.0.0

导包

import 'package:mini_calendar/mini_calendar.dart';

月视图(MonthWidget)

MonthWidget();// 默认当月
  • 可通过控制器参数来控制显示的月份以及选择的日期
MonthWidget(
  controller: MonthController.init(
      MonthOption<String>(
        currentDay: DateDay.now().copyWith(month: index + 1, day: Random().nextInt(27) + 1),
        currentMonth: DateMonth.now().copyWith(month: index + 1),
      )
  ),
)
  • 支持显示连选
MonthWidget(
  controller: MonthController.init(MonthOption(
    currentMonth: DateMonth.now().copyWith(month: 1),
    enableContinuous: true,
    firstSelectDay: DateDay.now().copyWith(month: 1, day: 8),
    secondSelectDay: DateDay.now().copyWith(month: 1, day: 18),
  )),
)
  • 支持多选
MonthWidget(
  controller: MonthController.init(MonthOption(
    currentMonth: DateMonth.now().copyWith(month: 1),
    enableMultiple: true,
    multipleDays: [
            DateDay.now().copyWith(month: 1, day: 3),
            DateDay.now().copyWith(month: 1, day: 5),
            DateDay.now().copyWith(month: 1, day: 8),
          ],
  )),
)
  • 支持添加标记
  • ……

image.png

滚动日历(MonthPageView)

控制器需要创建后获取 onCreated

MonthPageView<T>(
  padding: EdgeInsets.all(1),
  scrollDirection: Axis.horizontal,// 水平滑动或者竖直滑动
  option: MonthOption<T>(
    enableContinuous: true,// 单选、连选控制
    marks: { 
      DateDay.now().copyWith(day: 1): '111',
      DateDay.now().copyWith(day: 5): '222',
      DateDay.now().copyWith(day: 13): '333',
      DateDay.now().copyWith(day: 19): '444',
      DateDay.now().copyWith(day: 26): '444',
    },
  ),
  showWeekHead: true, // 显示星期头部
  onContinuousSelectListen: (DateDay?firstDay,DateDay?endFay) {
  },// 连选回调
  onMultipleSelectListen: (list) {
  },// 多选回调
  onMonthChange: (month) {
  },// 月份更改回调
  onDaySelected: (DateDay day, T? markData, bool enable) {
    // enable : 是否是可选日期
  },// 日期选中会迪欧啊
  onCreated: (controller){
  }, // 控制器回调
  onClear: () {
  }// 点击清空按钮,设置为空时不显示清空按钮
),

控制器

参数初始化

MonthOption({
    DateDay currentDay,//选择的日期
    DateMonth currentMonth,//当前月份
    int firstWeek = 7,//第一列显示的星期 [1,7]
    DateDay firstSelectDay,//连选第一个日期
    DateDay secondSelectDay,//连选第二个日期
    bool enableContinuous = false,//是否支持连选
    Map<DateDay, T> marks = const {},//标记
    List<DateDay>? multipleDays, // 多选日期
    List<DateDay>? enableDays, // 能选择的日期集合
    bool enableMultiple = false,//是否支持多选
    DateDay minDay,//可选的最小日期
    DateDay maxDay,//可选的最大日期
  });

注销

MonthPageController#dispose();

更新

MonthPageController#reLoad();

下一月

MonthPageController#next();

上一月

MonthPageController#last();

跳转到指定月份

MonthPageController#goto(DateMonth month);

演示

高级功能

自定义

自定义月视图背景

buildMonthBackground: (_, width, height, month) => Image.network(
    'https://ssyerv1.oss-cn-hangzhou.aliyuncs.com/picture/b0c57bd90abd49d59920924010ab66a9.png!sswm',
    height: height,
    width: width,
    fit: BoxFit.cover,
    ),

自定义月视图头部

buildMonthHead: (ctx, width, height, month) => Container(
padding: EdgeInsets.all(5),
child: Row(
  mainAxisAlignment: MainAxisAlignment.start,
  children: <Widget>[
    Text(
      "${month.year}年",
      style: TextStyle(fontSize: 40, color: Colors.white),
    ),
    Container(
      margin: EdgeInsets.only(left: 5, right: 5),
      width: 1,
      color: Colors.yellow,
      height: 50,
    ),
    Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Text(
          "${month.month}月",
          style: TextStyle(fontSize: 18, color: Colors.orange),
        ),
        Text("这是一个自定义的月头部"),
      ],
    )
  ],
),
),
  • 自定义星期头部
  • 自定义日视图
  • ……
image.png image.png

更多功能clone项目,运行demo

开源不易,老铁们多多支持,点赞也是支持 😃

More Repositories

1

Flutter-Notebook

FlutterDemo合集,今天你fu了吗
Dart
7,138
star
2

flutter_screenutil

Flutter screen adaptation, font adaptation, get screen information
Dart
3,783
star
3

fluwx

Flutter版微信SDK.WeChat SDK for flutter.
Dart
3,013
star
4

tobias

AliPay For Flutter.支付宝Flutter插件
Objective-C
655
star
5

PullToRefresh

Flutter相关的项目QQ:277155832 Email:[email protected]
Dart
470
star
6

flutter_oktoast

a pure flutter toast library
Dart
457
star
7

k_chart

Maybe it is the best k chart in Flutter.
Dart
430
star
8

Pangolin

🐾 Flutter 广告SDK-字节跳动-穿山甲 集成
Java
328
star
9

OpenFlutter

Love flutter love life.QQ群:892398530
301
star
10

flutter_listview_loadmore

flutter loadmore demos
Dart
242
star
11

flutter_share_me

Flutter Plugin for sharing contents to social media. You can use it share to Facebook , WhatsApp , Twitter And System Share UI. Support Url and Text.
Swift
148
star
12

nautilus

阿里百川电商Flutter插件。
Objective-C
129
star
13

mmkv_flutter

get or set persistent storage value based on MMKV framework.
Dart
101
star
14

flutter_im_demo

📞 Flutter 使用 MQTT实现IM功能
Dart
81
star
15

rammus

Flutter Plugin for AliCloud Push.阿里云推送插件
Kotlin
77
star
16

flutter_gesture_password

flutter_gesture_password
Dart
77
star
17

neeko

Flutter video player widget based on video_player
Dart
71
star
18

FlutterInAction

Flutter In Action.Flutter实践。
46
star
19

flutter_ok_image

a flutter image widget to load image.
Dart
40
star
20

sona

@Deprecated Not maintained. Developers who need Getui push please visit official plugins
Objective-C
35
star
21

flutter_database_demo

🛠 Flutter 本地数据库存储 + 状态管理
Dart
34
star
22

tencent_cos

Flutter plugin for cos
Java
23
star
23

flutter_paging

Paging like android jetpack
Dart
11
star
24

flutter_navigation_bar

解决官方例子会不停销毁重建的问题
Dart
10
star
25

kart

A kotlin-style extension collection for dart.
Dart
7
star
26

flutter_ali_face_verify

Flutter plugin for Ali face verify
Dart
1
star