multi_date_range_picker 0.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

Multi Date Range Picker #

A simple and customize Date range picker with multi range

Features #

  • Create Multi Range picker
  • Support multi language (with intl localization)

Getting Started #

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  multi_date_range_picker: "^0.0.4"

In your library add the following import:

import 'package:flutter_slidable/flutter_slidable.dart';

and use MultiDateRangePicker Widget to show

MultiDateRangePicker(
  initialValue: [],
  onChanged: (List<List<DateTime>> intervals) {
    
  },
);

Customization #

You can change colors of selection and background and more.

onlyOne = false // Allow only one selection
selectionColor = Colors.lightGreenAccent // Sets the color of the selection
buttonColor = Colors.lightGreenAccent // Sets the color of the buttons
primaryTextColor = Colors.black // Sets the color of UI text
dateTextColor = Colors.black // Sets the color of calendar date
ignoreTextColor = Colors.grey // Sets the color of external calendar date
selectedDateTextColor = Colors.black // Sets the color of calendar date when is selected
selectedIgnoreTextColor = Colors.black // Sets the color of external calendar date when is selected
backgroundTextColor = Colors.white // Sets the background color

Note #

For the customization of the local you will need at the start of your application to define the default local in intl

Intl.defaultLocale = 'fr';
initializeDateFormatting();

[0.0.4] - Add calendar localization. #

  • Start of week is now corresponds to intl local

[0.0.3] - Bad intl version. #

  • Set same version of intl for flutter.

[0.0.2] - Tiny Fix. #

  • Fix dartdoc generation.
  • Fix pubspec description.

[0.0.1] - First Version. #

  • Add multi date range picker.
  • Add initial value field.
  • Add callback on change value.
  • Add colors customizations.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:multi_date_range_picker/multi_date_range_picker.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';

void main() {

  Intl.defaultLocale = Intl.verifiedLocale(Platform.localeName, NumberFormat.localeExists,
      onFailure: (_) => 'en_US');
  initializeDateFormatting();

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyAppPage(),
    );
  }
}

class MyAppPage extends StatefulWidget {
  const MyAppPage({Key key}) : super(key: key);

  @override
  _MyAppPageState createState() => _MyAppPageState();
}

class _MyAppPageState extends State<MyAppPage> {
  List<List<DateTime>> intervals = [];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Multi Date Range Picker'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          children: <Widget>[
            MultiDateRangePicker(
              initialValue: intervals,
              onChanged: (List<List<DateTime>> intervals) {
                setState(() {
                  this.intervals = intervals;
                });
              },
              selectionColor: Colors.lightBlueAccent,
              buttonColor: Colors.lightBlueAccent,
            ),
            SizedBox(
              height: 16,
            ),
            Row(
              children: <Widget>[
                Expanded(
                  child: Card(
                    child: Padding(
                      padding: const EdgeInsets.symmetric(
                          horizontal: 8.0, vertical: 16.0),
                      child: Column(
                        children: buildColumn(),
                      ),
                    ),
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }

  List<Widget> buildColumn() {
    final List<Widget> list = [];

    for (final interval in intervals) {
      list.add(Text(interval[0].toString() + " - " + interval[1].toString()));
      if (interval != intervals.last)
        list.add(SizedBox(
          height: 8,
        ));
    }

    return list;
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  multi_date_range_picker: ^0.0.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:multi_date_range_picker/multi_date_range_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
55
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
76
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • multi_date_range_picker that is a package requiring null.

Health suggestions

Format lib/multi_date_range_picker.dart.

Run flutter format to format lib/multi_date_range_picker.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
intl ^0.16.0 0.16.1
meta ^1.1.8 1.1.8 1.2.2
quiver ^2.0.5 2.1.3
Transitive dependencies
collection 1.14.12 1.14.13
matcher 0.12.8
path 1.7.0
sky_engine 0.0.99
stack_trace 1.9.5
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test