Building a Flutter DateTime Picker in just 15 minutes

Search for a command to run...

No comments yet. Be the first to comment.
This series focuses on introducing you to short and crisp code snippets to build beautiful UI & concise UX with Flutter. These are specifically aligned to help newbie Flutter Devs.
The pull-to-refresh pattern lets a user pull down on a list of data using touch in order to retrieve more data. The "Pull-to-refresh" gesture was first introduced by Loren Brichter in the Tweetie app and in no time it became so popular that countless...
The offer came via on-campus hiring at Thapar Institute, Patiala. Navi came to our campus in September 2021 to hire Fresh Graduates for SDE-1 roles. Company 💪🏻 At Navi, our mission is to build financial services that are simple, accessible, and af...

Agenda? A lot of people ask me, how to get started with tech. If you have been asking this to someone, this might be the answer. Let me try to answer it by taking some relevant programming fields in context. Options? According to me, there are four m...

It was a cold winter night of November when I was scrolling through my LinkedIn and a mail popped up on my cell phone. The subject said, "2021 Application Engineering Internship Opportunity with Google India!". At first, I was like, "Ahh.. this seems...

❔ Intro to JPMC’s Code for Good According to JPMorgan Chase & Co., Code for Good is a series of hackathons hosted in JPMorgan’s global technology centers. During this event, participants spend 12–24 hours with our employees, developing creative solu...

The AlertDialog is basically a Popup in Flutter. Whenever you want to create a floating box that is centered on the page, you can simply use an AlertDialog. The implementation of the same is very easy and has been provided in-built with Flutter SDK. ...

Shivam's Blog
9 posts
Hey! I'm Shivam. I'm an award-winning Software Engineer & a CS major with a background in Full Stack Mobile Engineering.
More about me? https://goyalshivam.com/ it is.
With the Flutter DateTime Picker plugin, you can add date & time pickers to your native application. The plugin’s interface is inspired by the iOS Cupertino style menu.
In this tutorial, you’ll build a mobile app featuring a DateTime Picker using the Flutter SDK. Your app will:
Display separate Date & Time Pickers with a minimalistic interface
Display the selected data as outputs to console

This tutorial focuses on adding a DateTime Picker to a Flutter app. Non-relevant concepts and code blocks are glossed over and are provided for you to simply copy and paste.
The detailed steps to install Flutter on your personal computer & getting started with Flutter is available in the following blog
The basic format of a DateTime Picker looks like the one below:
Adding the additional capability to a Flutter app is easy using Pub packages. In this tutorial, you introduce the DateTime Picker plugin by adding a single line to the pubspec.yaml file.
Import flutter_datetime_picker dependency to your main.dart file by adding the following line at the starting of the file:
Amend your main.dart file as per the following code:
Connect your Emulator or physical Android device to test the application.
Click on Build & Run.
And Boooom, your app is ready. The final build would look like the below illustration.

There are three functional variations of the plugin available as follows:
Solo DatePicker
Solo TimePicker
Dual DateTimePicker
There are various language options available to implement the plugin for international use. For changing the language of the component amend the following with preferred LocaleType.
locale: LocaleType.en
English(en)
Persian(fa)
Chinese(zh)
Dutch(nl)
Russian(ru)
Italian(it)
French(fr)
Spanish(es)
Polish (pl)
Portuguese(pt)
Korean(ko)
Arabic(ar)
Turkish(tr)
Japanese(jp)
German(de)
Danish(da)
Bengali(bn)
Vietnamese(vi)
Armenian(hy)
If you want to customize your own style of date time picker, there is a class called CommonPickerModel, every type of date time picker is extended from this class, you can refer to other picker models (eg. DatePickerModel), and write your custom one, then pass this model to showPicker method, so that your own date time picker will appear, it’s easy, and will perfectly meet your demand.
How to customize your own picker model: