Saturday, 6 July 2019

Flutter date pickers without dialog

flutter tutorial,flutter,flutter tutorial for beginners,flutter app,flutter tutorials,flutter sdk,tutorial,flutter course,learn flutter,flutter tutorial ios,flutter firebase tutorial,flutter widgets,flutter app development tutorial,flutter ios,flutter dart,flutter android,google flutter,flutter sdk tutorial,flutter tutorial app,google flutter tutorial,flutter sqflite tutorial,flutter tutorial deutsch,flutter tutorial android

flutter_date_pickers

Allows to use date pickers without dialog. Provides some customizable styles for date pickers.
A set of date pickers:
  • DayPicker for one day
  • WeekPicker for whole week
  • RangePicker for random range
  • MonthPicker for month
flutter tutorial,flutter,flutter tutorial for beginners,flutter app,flutter tutorials,flutter sdk,tutorial,flutter course,learn flutter,flutter tutorial ios,flutter firebase tutorial,flutter widgets,flutter app development tutorial,flutter ios,flutter dart,flutter android,google flutter,flutter sdk tutorial,flutter tutorial app,google flutter tutorial,flutter sqflite tutorial,flutter tutorial deutsch,flutter tutorial android


How to style date picker

Every date picker constructor take a style object as a parameter (if no styles passed - defaults will be used).
For single value pickers (DayPicker, MonthPicker) it is DatePickerStyles object;
For range pickers (WeekPicker, RangePickers) it is DatePickerRangeStyles object;
Customizable styles:
for all date pickers
PROPERTYDESCRIPTION
TextStyle displayedPeriodTitletitle of the date picker
TextStyle currentDateStylestyle for current date
TextStyle disabledDateStylestyle for disabled dates (before first and after last date user can pick)
TextStyle selectedDateStylestyle for selected date
BoxDecoration selectedSingleDateDecorationdecoration for selected date in case single value is selected
TextStyle defaultDateTextStylestyle for date which is neither current nor disabled nor selected
only for range date pickers (WeekPicker, RangePicker)
PROPERTYDESCRIPTION
BoxDecoration selectedPeriodStartDecorationdecoration for the first date of the selected range
BoxDecoration selectedPeriodLastDecorationdecoration for the first date of the selected range
BoxDecoration selectedPeriodMiddleDecorationDecoration for the date of the selected range which is not first date and not end date of this range

Usage

// Create week date picker with passed parameters
Widget buildWeekDatePicker (DateTime selectedDate, DateTime firstAllowedDate, DateTime lastAllowedDate, ValueChanged<DatePeriod> onNewSelected) {

 // add some colors to default settings
    DatePickerRangeStyles styles = DatePickerRangeStyles(
      selectedPeriodLastDecoration: BoxDecoration(
          color: Colors.red,
          borderRadius: BorderRadius.only(
              topRight: Radius.circular(10.0),
              bottomRight: Radius.circular(10.0))),
      selectedPeriodStartDecoration: BoxDecoration(
        color: Colors.green,
        borderRadius: BorderRadius.only(
            topLeft: Radius.circular(10.0), bottomLeft: Radius.circular(10.0)),
      ),
      selectedPeriodMiddleDecoration: BoxDecoration(
          color: Colors.yellow, shape: BoxShape.rectangle),
    );
    
  return WeekPicker(
      selectedDate: selectedDate,
      onChanged: onNewSelected,
      firstDate: firstAllowedDate,
      lastDate: lastAllowedDate,
      datePickerStyles: styles
  );

GitHub

— Read More
Latest commit to the master branch on 4-19-2019
Download as zip