date_picker_v2 0.0.3 copy "date_picker_v2: ^0.0.3" to clipboard
date_picker_v2: ^0.0.3 copied to clipboard

discontinuedreplaced by: easy_date_picker

A simple and easy to use date-picker widget

Date Picker #

A simple and easy to use date-picker widget.

How to use #

Properties Description
onChanged It will be called when the user selects a date with the selected year, month, and day.
beginYear ...
endYear ...
ascendingyear ...
lableYear ...
lableMonth ...
lableDay ...

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('MyHomePage'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(24.0),
        child: Column(
          children: [
            const SizedBox(height: 24.0),
            DatePicker(
              onChanged: (year, month, day) => print('$year, $month, $day'),
            ),
            const SizedBox(height: 24.0),
            DatePicker(
              beginYear: 2020,
              endYear: 2029,
              onChanged: (year, month, day) => print('$year, $month, $day'),
            ),
            const SizedBox(height: 24.0),
            DatePicker(
              beginYear: 2020,
              endYear: 2029,
              ascendingYear: false,
              onChanged: (year, month, day) => print('$year, $month, $day'),
            ),
            const SizedBox(height: 24.0),
            ElevatedButton(
              onPressed: () {
                showDialog(
                  context: context,
                  builder: (_) => const DatePickerDialog(),
                );
              },
              child: const Text('Select a date in a dialog'),
            ),
          ],
        ),
      ),
    );
  }
}

class DatePickerDialog extends StatelessWidget {
  const DatePickerDialog({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      content: Padding(
        padding: const EdgeInsets.all(24.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          mainAxisSize: MainAxisSize.min,
          children: [
            DatePicker(
              onChanged: (year, month, day) => print('$year, $month, $day'),
            ),
            const SizedBox(height: 24.0),
            ElevatedButton(
              onPressed: () => Navigator.of(context).pop(),
              child: const Text('Close'),
            )
          ],
        ),
      ),
    );
  }
}
0
likes
150
pub points
48%
popularity

Publisher

unverified uploader

A simple and easy to use date-picker widget

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on date_picker_v2