Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make range date picker in flutter

I am trying to make a date range picker like this ,date picker start with on value (today value) then user select the range he need ,in flutter finally I found this package.

But I can't open it when I click on the button as date picker.

I trayed to use another package date range picker but it doesn't help me! enter image description here

like image 310
amira syam Avatar asked Jul 14 '26 02:07

amira syam


1 Answers

Flutter has now an inbuilt date range picker below is an example of using it

IconButton(
        onPressed: () async {
          final picked = await showDateRangePicker(
            context: context,
            lastDate: endDate,
            firstDate: new DateTime(2019),
          );
          if (picked != null && picked != null) {
            print(picked);
            setState(() {
              startDate = picked.start;
              endDate = picked.end;
//below have methods that runs once a date range is picked 
              allWaterBillsFuture = _getAllWaterBillsFuture(
                  picked.start.toIso8601String(),
                  picked.end
                      .add(new Duration(hours: 24))
                      .toIso8601String());
            });
          }
        },
        icon: Icon(
          Icons.calendar_today,
          color: Colors.white,
        ),
      ),
like image 52
Nelson Bwogora Avatar answered Jul 17 '26 19:07

Nelson Bwogora



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!