FLUTTER ECOSYSTEM

hyoeun-dev/simple_date_picker

三种风格的 Cupertino 日期选择器

simple_date_picker 项目封面
Stars
2
Forks
0
最近推送(UTC)
2025年2月28日
项目状态
未归档
HYOEUN LEE GitHub avatar
GITHUB User

HYOEUN LEE ↗

语言C++CCMakeDartSwiftHTMLKotlinObjective-C

使用的依赖

依赖清单 3 项
  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_lints开发依赖^4.0.0

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

Simple Date Picker

SHOWCASE
https://raw.githubusercontent.com/hashtag-mood/simple_date_picker/refs/heads/main/SHOWCASE.gif
GETTING STARTED

Run the following command in your terminal to get started

 $ flutter pub add simple_date_picker
USAGE

COMPLETE EXAMPLE is here

SET UP

Create an instance of SimpleDatePicker and define DateTimes for each picker

SimpleDatePicker simpleDatePicker = SimpleDatePicker();
DateTime yearMonthDayDateTime = DateTime.now();
DateTime yearMonthDateTime = DateTime.now();
DateTime yearDateTime = DateTime.now();
int firstYear = 1950;
int lastYear = 2050;

EXAMPLE

Align(
              alignment: Alignment.center,
              child: TextButton(
                  onPressed: () async {
                    await showCupertinoModalPopup(
                      context: context,
                      builder: (context) {
                        return simpleDatePicker.yearMonthDayPicker(
                          yearMonthDayDateTime: yearMonthDayDateTime,
                          monthCallback: (int index) {
                            setState(() {
                              yearMonthDayDateTime = DateTime(
                                  yearMonthDayDateTime.year,
                                  index + 1,
                                  yearMonthDayDateTime.day);
                            });
                          },
                          dayCallback: (int index) {
                            setState(() {
                              yearMonthDayDateTime = DateTime(
                                  yearMonthDayDateTime.year,
                                  yearMonthDayDateTime.month,
                                  index + 1);
                            });
                          },
                          yearCallback: (int index) {
                            setState(() {
                              yearMonthDayDateTime = DateTime(
                                  firstYear + index,
                                  yearMonthDayDateTime.month,
                                  yearMonthDayDateTime.day);
                            });
                          },
                          firstYear: firstYear,
                          lastYear: lastYear,
                        );
                      },
                    );
                  },
                  child: Text(
                    '${yearMonthDayDateTime.year}년 ${yearMonthDayDateTime.month}월 ${yearMonthDayDateTime.day}일',
                    style: const TextStyle(
                      fontSize: 20,
                      color: Colors.black,
                      fontWeight: FontWeight.normal,
                    ),
                  )),
            );