date_ranger 1.0.1 copy "date_ranger: ^1.0.1" to clipboard
date_ranger: ^1.0.1 copied to clipboard

A date picker for flutter apps to pick single dates and date ranges

example/example.dart

import 'package:date_ranger/date_ranger.dart';
import 'package:flutter/material.dart';

class Example extends StatefulWidget {
  @override
  _ExampleState createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  var initialDate = DateTime.now();
  var initialDateRange =
      DateTimeRange(start: DateTime.now(), end: DateTime.now());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Container(),
        Padding(
          padding: const EdgeInsets.all(24),
          child: DateRanger(
            initialRange: initialDateRange,
            onRangeChanged: (range) {
              setState(() {
                initialDateRange = range;
              });
            },
          ),
        )
      ],
    ));
  }

  DateRanger singleDatePicker() {
    return DateRanger(
      initialDate: initialDate,
      rangerType: DateRangerType.single,
      onRangeChanged: (range) {
        setState(() {
          initialDate = range.start;
        });
      },
    );
  }

  DateRanger dateRangePicker() {
    return DateRanger(
      initialRange: initialDateRange,
      onRangeChanged: (range) {
        setState(() {
          initialDateRange = range;
        });
      },
    );
  }
}
30
likes
80
pub points
81%
popularity

Publisher

unverified uploader

A date picker for flutter apps to pick single dates and date ranges

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, intl

More

Packages that depend on date_ranger