DEV Community

Parth
Parth

Posted on

3

Creating a Date Picker #Flutter

this tutorial focuses on adding a Date Picker to a Flutter app.

so let's do this...

we will first create a simple button on which we can press and get our date picker pop.

FlatButton(
    child: Text("Date: " + selectedDate.toString()),
    onPressed: () async{
        DateTime date = await showDatePicker(
        context: context, 
        initialDate: DateTime.now(), 
        firstDate: DateTime(2010), 
        lastDate: DateTime.now().add(Duration(days: 1)));

        if (date != null){
            setState((){
                selectedDate = date;
            });
        }
    },
)
Enter fullscreen mode Exit fullscreen mode

here, the initialDate represents the current selected date, firstDate represents the date from where your calendar will start and the lastDate represents the ending date of your calendar.

you can even use it's "then" function to get the value selected from that picker.

so that's it go and try.

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more