Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter_rounded_date_picker

the flutter plugin that help you can choose dates and years with rounded calendars and customizable themes.

date picker

a3

a4

a5

installing

add dependencies in pubspec.yaml file. add 2 things in it including flutter_localizations

dependencies:
  flutter_localizations:
    sdk: flutter
  flutter_rounded_date_picker: 1.0.0

importing

import packages into your dart.

import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_rounded_date_picker/rounded_picker.dart';

initialize localizations

add localization delegates in materialapp widget and add languages that your app supports.

materialapp(
    localizationsdelegates: [
          globalmateriallocalizations.delegate,
          globalwidgetslocalizations.delegate,
    ],
    supportedlocales: [
          const locale('en', 'us'), // english
          const locale('th', 'th'), // thai
    ],
    ...
)

show date picker

show date picker which you can specify a date that allows users to choose.

datetime newdatetime = await showroundeddatepicker(
  context: context,
  initialdate: datetime.now(),
  firstdate: datetime(datetime.now().year - 1),
  lastdate: datetime(datetime.now().year + 1),
  borderradius: 16,
),

1-1

a1

show year picker

show year picker which you can specify a year start and end that allows users to choose.

datetime newdatetime = await showroundeddatepicker(
  context: context,
  initialdatepickermode: datepickermode.year,
  theme: themedata(primaryswatch: colors.green),
);

8

theme

you can assign themes to the date picker by using themedata class and primaryswatch.

datetime newdatetime = await showroundeddatepicker(
  context: context,
  theme: themedata(primaryswatch: colors.pink),
);

2-1

dark theme

datetime newdatetime = await showroundeddatepicker(
  context: context,
  theme: themedata.dark(),
);

3-1

custom theme with themedata

datetime newdatetime = await showroundeddatepicker(
  context: context,
  background: colors.white,
  theme: themedata(
    primarycolor: colors.red[400],
    accentcolor: colors.green[800],
    dialogbackgroundcolor: colors.purple[50],
    texttheme: texttheme(
      body1: textstyle(color: colors.red),
      caption: textstyle(color: colors.blue),
    ),
    disabledcolor: colors.orange,
    accenttexttheme: texttheme(
      body2 : textstyle(color: colors.green[200]),
    ),
  ),
);

9

customize date picker

you can use styledatepicker field for date picker style such as font size, weight, text color each part in the date picker.

example custom font size and padding for displaying on a tablet. (pixel c, ipad 9.7″)

datetime newdatetime = await showroundeddatepicker(
                        context: context,
                        theme: themedata(primaryswatch: colors.deeppurple),
                        styledatepicker: materialroundeddatepickerstyle(
                          textstyledaybutton: textstyle(fontsize: 36, color: colors.white),
                          textstyleyearbutton: textstyle(
                            fontsize: 52,
                            color: colors.white,
                          ),
                          textstyledayheader: textstyle(
                            fontsize: 24,
                            color: colors.white,
                          ),
                          textstylecurrentdayoncalendar:
                              textstyle(fontsize: 32, color: colors.white, fontweight: fontweight.bold),
                          textstyledayoncalendar: textstyle(fontsize: 28, color: colors.white),
                          textstyledayoncalendarselected:
                              textstyle(fontsize: 32, color: colors.white, fontweight: fontweight.bold),
                          textstyledayoncalendardisabled: textstyle(fontsize: 28, color: colors.white.withopacity(0.1)),
                          textstylemonthyearheader:
                              textstyle(fontsize: 32, color: colors.white, fontweight: fontweight.bold),
                          paddingdatepicker: edgeinsets.all(0),
                          paddingmonthheader: edgeinsets.all(32),
                          paddingactionbar: edgeinsets.all(16),
                          paddingdateyearheader: edgeinsets.all(32),
                          sizearrow: 50,
                          colorarrownext: colors.white,
                          colorarrowprevious: colors.white,
                          marginleftarrowprevious: 16,
                          margintoparrowprevious: 16,
                          margintoparrownext: 16,
                          marginrightarrownext: 32,
                          textstylebuttonaction: textstyle(fontsize: 28, color: colors.white),
                          textstylebuttonpositive:
                              textstyle(fontsize: 28, color: colors.white, fontweight: fontweight.bold),
                          textstylebuttonnegative: textstyle(fontsize: 28, color: colors.white.withopacity(0.5)),
                          decorationdateselected: boxdecoration(color: colors.orange[600], shape: boxshape.circle),
                          backgroundpicker: colors.deeppurple[400],
                          backgroundactionbar: colors.deeppurple[300],
                          backgroundheadermonth: colors.deeppurple[300],
                        ),
                        styleyearpicker: materialroundedyearpickerstyle(
                          textstyleyear: textstyle(fontsize: 40, color: colors.white),
                          textstyleyearselected:
                              textstyle(fontsize: 56, color: colors.white, fontweight: fontweight.bold),
                          heightyearrow: 100,
                          backgroundpicker: colors.deeppurple[400],
                        ));

18

23

24

custom action button and text on button.

added the action button and the button’s custom text.

datetime newdatetime = await showroundeddatepicker(
                        ...
                        textactionbutton: "action",
                        ontapactionbutton: (){
                           //
                        },
                        textpositivebutton: "ok",
                        textnegativebutton: "cancel");

19

custom weekday header text.

customize the header of the weekday.

datetime newdatetime = await showroundeddatepicker(
                        ...
                        customweekdays: ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]);

20

custom disabled date.

add closed date cannot be selected.

datetime newdatetime = await showroundeddatepicker(
                        ...
                        listdatedisabled: [
                                                  datetime.now().subtract(duration(days: 2)),
                                                  datetime.now().subtract(duration(days: 4)),
                                                  datetime.now().subtract(duration(days: 6)),
                                                  datetime.now().subtract(duration(days: 8)),
                                                  datetime.now().subtract(duration(days: 10)),
                                                  datetime.now().add(duration(days: 2)),
                                                  datetime.now().add(duration(days: 4)),
                                                  datetime.now().add(duration(days: 6)),
                                                  datetime.now().add(duration(days: 8)),
                                                  datetime.now().add(duration(days: 10)),
                                                ]);

21

custom callback on tap day.

add callback when tap on day.

datetime newdatetime = await showroundeddatepicker(
                        ...
                        ontapday: (datetime datetime, bool available) {
                          if (!available) {
                            showdialog(
                                context: context,
                                builder: (c) => cupertinoalertdialog(title: text("this date cannot be selected."),actions: <widget>[
                                  cupertinodialogaction(child: text("ok"),onpressed: (){
                                    navigator.pop(context);
                                  },)
                                ],));
                          }
                          return available;
                        });

a6

custom builder day on date picker.

customize the display format of the day widget.

datetime newdatetime = await showroundeddatepicker(
                        ...
                        builderday:
                            (datetime datetime, bool iscurrentday, bool isselected, textstyle defaulttextstyle) {
                          if (isselected) {
                            return container(
                              decoration: boxdecoration(color: colors.orange[600], shape: boxshape.circle),
                              child: center(
                                child: text(
                                  datetime.day.tostring(),
                                  style: defaulttextstyle,
                                ),
                              ),
                            );
                          }

                          if (datetime.day == 10) {
                            return container(
                              decoration: boxdecoration(
                                  border: border.all(color: colors.pink[300], width: 4), shape: boxshape.circle),
                              child: center(
                                child: text(
                                  datetime.day.tostring(),
                                  style: defaulttextstyle,
                                ),
                              ),
                            );
                          }
                          if (datetime.day == 12) {
                            return container(
                              decoration: boxdecoration(
                                  border: border.all(color: colors.pink[300], width: 4), shape: boxshape.circle),
                              child: center(
                                child: text(
                                  datetime.day.tostring(),
                                  style: defaulttextstyle,
                                ),
                              ),
                            );
                          }

                          return container(
                            child: center(
                              child: text(
                                datetime.day.tostring(),
                                style: defaulttextstyle,
                              ),
                            ),
                          );
                        });

22

image background header

use images as the header of the date picker and you can also add more details.

  • you need to specify the path of images in your asset (pubspec.yaml).
datetime newdatetime = await showroundeddatepicker(
  context: context,
  theme: themedata(primaryswatch: colors.blue),
  imageheader: assetimage("assets/images/calendar_header.jpg"),
  description: "lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
);

4-1

customize font in date picker

you can adjust the font-family in the date picker.

  • you need to specify the path of font in your fonts (pubspec.yaml).
datetime newdatetime = await showroundeddatepicker(
  context: context,
  fontfamily: "mali"
);

5-1

date picker locale

you can set the date picker locale. by specifying the language code and country code.
as of april 2019, this package supports about 52 languages.

datetime newdatetime = await showroundeddatepicker(
  context: context,
  locale: locale("zh","cn"),
  theme: themedata(primaryswatch: colors.pink),
);

6-1

thai and buddhist year

if you are using thai language and use the buddhist era (543 bce). plugins that support these capabilities.

datetime newdatetime = await showroundeddatepicker(
  context: context,
  locale: locale("th", "th"),
  era: eramode.buddhist_year,
);

7

show time picker

show time picker, all feature of date picker is available (except description)

final timepicked = await showroundedtimepicker(
  context: context,
  initialtime: timeofday.now(),
);

17

cupertino date picker

show date and duration picker ios style.

installing

add flutter cupertino localizations in dependencies pub.yaml.

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  flutter_cupertino_localizations: 1.0.1

initialize localizations

add cupertinolocalizations delegate to localizations delegate on your app.
the cupertino date picker will use current app locale in picker.

materialapp(
  debugshowcheckedmodebanner: false,
  localizationsdelegates: [
    globalmateriallocalizations.delegate,
    globalwidgetslocalizations.delegate,
    defaultcupertinolocalizations.delegate,
    globalcupertinolocalizations.delegate,  // add global cupertino localiztions.
  ],
  locale: locale('en', 'us'),  // current locale
  supportedlocales: [
    const locale('en', 'us'), // english
    const locale('th', 'th'), // thai
  ],
)

show cupertino date picker

call the method for displaying date picker.
the callback date time instance will be return with ondatetimechange.

cupertinoroundeddatepicker.show(
  context,
  fontfamily: "mali",
  textcolor: colors.white,
  background: colors.red[300],
  borderradius: 16,
  initialdatepickermode: cupertinodatepickermode.date,
  ondatetimechanged: (newdatetime) {
    //
  },
);

12

more cupertino date picker mode

cupertinodatepickermode.date
cupertinodatepickermode.dateandtime
cupertinodatepickermode.time

10

11

using thai and buddhist year

/// current locale is th.
cupertinoroundeddatepicker.show(
  context,
  fontfamily: "mali",
  textcolor: colors.white,
  era: eramode.buddhist_year,
  background: colors.red[300],
  borderradius: 16,
  initialdatepickermode: cupertinodatepickermode.date,
  ondatetimechanged: (newdatetime) {
    //
  },
);

13

cupertino duration picker

in ios , flutter cupertino support duration and timer picker.

cupertinoroundeddurationpicker.show(
  context,
  initialtimerduration: duration(minute:10),
  initialdurationpickermode: cupertinotimerpickermode.hms,
  fontfamily: "mali",
  ondurationchanged: (newduration) {
    //
  },
);

14

more cupertino duration picker mode

cupertinotimerpickermode.hms
cupertinotimerpickermode.hm
cupertinotimerpickermode.ms

15

16


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.