Getting started

A Flutter package to pick date with number only. Date Picker Dialog Date selected

Usage

To use this package: -add the dependency to your pubspec.yaml file

dependencies:
  flutter:
      sdk: flutter

  number_date_picker: <latest-package>

Then you can use the package

ElevatedButton(
    onPressed: () => showDateNumPicker(
    context: context,
    startYear: 2000,
    endYear: 2023,
    initialDate: selectedDate,
    onDaySelected: (DateTime? dateTime) {
        setState(() {
        selectedDate = dateTime as DateTime;
        });
      },
    ),
    child: const Text('Select Date'))

Show the selected date

Container(
    padding: const EdgeInsets.all(20),
    decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(5),
        boxShadow: const [
          BoxShadow(
              spreadRadius: 2, blurRadius: 2, color: Colors.black12)
        ]),
    child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
        // day
        Text(
          DateFormat.d().format(selectedDate),
          style: const TextStyle(
              fontSize: 30, fontWeight: FontWeight.w800),
        ),
        const SizedBox(width: 3),
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            // month
            Text(
              DateFormat.MMM().format(selectedDate),
              style: const TextStyle(
                  fontSize: 12, fontWeight: FontWeight.w600),
            ),
            // year
            Text(
              DateFormat.y().format(selectedDate),
              style: const TextStyle(
                  fontSize: 12, fontWeight: FontWeight.w600),
            ),
          ],
        )
      ],
    ))

Libraries

number_date_picker