Date Range Picker

Loading preview

Starting the Flutter app

A showcase of Flutter's date range picker functionality

Get the source

Add it to your project

Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.

First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.

How it works

Two ListTiles each call showDatePicker and store the result in _start or _end. The end picker uses _start as its firstDate, and picking a start after the current end clears _end, so the range can’t invert. Apply Range stays disabled until both dates are set, then passes a DateTimeRange to onApply, or shows a demo SnackBar without it. _format prints dates as month/day/year.

Adapting it

  • Consider a single showDateRangePicker in place of both showDatePicker calls, since it returns a validated DateTimeRange.
  • Return the range with Navigator.pop from onApply, and format with intl’s DateFormat.