flutter Timeline Calendar Package

Pub License: MIT


时间轴日历

如何安装

将此添加到您的包的pubspec.yaml文件中

dependencies:
  flutter_timeline_calendar: ^1.0.1

然后您可以通过命令行安装包

$ pub get

或者

$ flutter pub get

或者,您的编辑器可能支持 flutter pub get。请查看您编辑器的文档以了解更多信息。

现在,在您的 Dart 代码中,您可以使用

import 'package:flutter_timeline_calendar/flutter_timeline_calendar.dart';

flutter Timeline Calendar Package

基本用法

您可以加载完整的日历。

    return TimelineCalendar(
          calendarType: CalendarType.GREGORIAN,
          calendarLanguage: "en",
          calendarOptions: CalendarOptions(
            viewType: ViewType.DAILY,
            toggleViewType: true,
            headerMonthElevation: 10,
            headerMonthShadowColor: Colors.black26,
            headerMonthBackColor: Colors.transparent,
          ),
          dayOptions: DayOptions(compactMode: true,weekDaySelectedColor: const Color(0xff3AC3E2)),
          headerOptions: HeaderOptions(
              weekDayStringType: WeekDayStringTypes.SHORT,
              monthStringType: MonthStringTypes.FULL,
              backgroundColor: const Color(0xff3AC3E2),
              headerTextColor: Colors.black),
          onChangeDateTime: (datetime) {
            print(datetime.getDate());
          },
        );

选项

您有许多选项可以更改:样式、区域设置和结构。

选项 类型
calendarType 日历类型 (JALALI 或 GREGORIAN)
calendarOptions 日历选项
headerOptions 标题选项
dayOptions 日期选项
calendarLanguage 字符串 (fa,en,pt)

事件

名称 描述
onInit 当 Timeline Calendar 对象插入到树中时调用。
onChangeDateTime 返回一个新选日期的字符串,如 (年-月-日)
onMonthChanged 当月份更改时,返回一个 CalendarDateTime 字符串 (年-月-日 时:分:秒)
onYearChanged 当年份更改时,返回一个 CalendarDateTime 字符串 (年-月-日 时:分:秒)
onDateTimeReset 点击重置按钮时,返回当前 CalendarDateTime 字符串 (年-月-日 时:分:秒)
onChangeViewType 点击切换视图类型时,返回 ViewType

CalendarOptions

选项 类型 描述
toggleViewType 布尔值 用户是否可以切换月视图和日视图
viewType 视图类型 日历的默认视图类型,日视图或月视图
font 字符串 您的字体名称
headerMonthBackColor 颜色 日历卡片的背景颜色
headerMonthShadowColor 颜色 日历卡片的阴影颜色
headerMonthElevation 双精度 日历卡片阴影的抬高量
headerMonthShape ShapeBorder 日历卡片的形状,如 (圆角矩形边框)
bottomSheetBackColor 颜色 选择月份和年份的底部工作表的背景颜色)

HeaderOptions

选项 类型 描述
weekDayStringType 星期几的字符串类型 星期几的名称,完整或简短
MonthStringTypes MonthStringTypes 月份的名称,完整或简短
headerTextColor 颜色 标题文本的颜色
navigationColor 颜色 标题导航图标的颜色
resetDateColor 颜色 重置日期的图标颜色
backgroundColor 颜色 标题和日历背景的颜色

DayOptions

选项 类型 描述
weekDaySelectedColor 颜色 选中星期几的颜色
weekDayUnselectedColor 颜色 未选中星期几的颜色
showWeekDay 布尔值 是否显示星期几
compactMode 布尔值 日历卡片是否是紧凑模式
selectedBackgroundColor 颜色 选中日期的背景颜色
unselectedBackgroundColor 颜色 未选中日期的背景颜色
selectedTextColor 颜色 选中日期的文本颜色
disabledTextColor 颜色 禁用日期的文本颜色
unselectedTextColor 颜色 未选中日期的文本颜色
disableFadeEffect 布尔值 当前日期之前的日期是否具有淡入效果
disableDaysBeforeNow 布尔值 当前日期之前的日期是否禁用

区域设置

Timeline Calendar 目前支持两种日历类型。公历日历

贡献

您可以帮助我们并贡献

  • 新选项
  • 更多区域设置
  • 更好的异常处理

GitHub

查看 Github