dropdown_date_picker 0.1.1+2 copy "dropdown_date_picker: ^0.1.1+2" to clipboard
dropdown_date_picker: ^0.1.1+2 copied to clipboard

A dropdown date picker package for date selection like year, month and day.

example/lib/main.dart

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

void main() => runApp(Example());

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

  static final now = DateTime.now();

  final dropdownDatePicker = DropdownDatePicker(
    firstDate: ValidDate(year: now.year - 100, month: 1, day: 1),
    lastDate: ValidDate(year: now.year, month: now.month, day: now.day),
    textStyle: TextStyle(fontWeight: FontWeight.bold),
    dropdownColor: Colors.blue[200],
    dateHint: DateHint(year: 'year', month: 'month', day: 'day'),
    ascending: false,
  );
}

class _ExampleState extends State<Example> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('DropdownDatePicker example'),
        ),
        body: Material(
          child: Center(
            child: SingleChildScrollView(
              child: Column(
                children: <Widget>[
                  widget.dropdownDatePicker,
                  RaisedButton(
                    onPressed: () => setState(
                      () => (debugPrint('Rebuild UI.')),
                    ),
                    child: const Text('Print current date.'),
                  ),
                  const SizedBox(
                    height: 40,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      const Text(
                        'Current date: ',
                        textAlign: TextAlign.center,
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Text(
                        widget.dropdownDatePicker.getDate('/'),
                        textAlign: TextAlign.center,
                      ),
                    ],
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      const Text(
                        'Current date: ',
                        textAlign: TextAlign.center,
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Text(
                        widget.dropdownDatePicker.getDate(),
                        textAlign: TextAlign.center,
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
14
likes
40
pub points
73%
popularity

Publisher

unverified uploader

A dropdown date picker package for date selection like year, month and day.

Repository (GitLab)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on dropdown_date_picker