• Courses
  • YouTube
  • Dev News
  • Technology
  • Blogs
  • Flutter Jobs
  • Contact
    • About Us
    • RegisterLogin
    Navoki
    • Courses
    • YouTube
    • Dev News
    • Technology
    • Blogs
    • Flutter Jobs
    • Contact
      • About Us
    • RegisterLogin

      Developers

      • Home
      • Blog
      • Developers
      • DATE TIME PICKER USING FLUTTER
      Date&Amp;Timepicker

      DATE TIME PICKER USING FLUTTER

      • Posted by Shivam Srivastava
      • Categories Developers, Flutter
      • Date March 16, 2020
      • Comments 0 comment
      Spread the love

      Introduction

      Using Flutter Date Time Picker Plugin you can add Date and Time picker in your flutter application.

      What do you learn here?

      In this tutorial, you’ll build a mobile app that includes a DateTime Picker using the Flutter SDK. Your app will:

      • Display Date and Time picker separately.
      • Display the selected data as outputs in Text Widgets.

      In this tutorial, we will focus on adding a Date_Time Picker in your flutter application and.

      Setup Flutter on your machine

      If you don’t have a flutter set up in your machine so you have to need to install it first. Click here to learn how to set up flutter on Windows and for Linux click here.

      Let’s Begin for the code.

      • Add flutter_datetime_picker and intl dependency in your project pubspec.yaml file.
      dependencies:
        flutter:
          sdk: flutter
        flutter_datetime_picker: <latest version>
        intl: <latest version>

      flutter_datetime_picker: This will show DateTime picker.
      intl: This dependency set format of choose selected date or time.

      Run flutter packages get command on terminal

      • Add the below code in your main.dart file for import dependency.
      import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
      import 'package:intl/intl.dart';

      Now we are ready for Coding the component.

      Date Picker component code.

      Datepicker | Date Time Picker Using Flutter
        String _selectedDate;
       Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  Text(" ${_selectedDate??'Selected Date'}",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18),),
                  RaisedButton(
                    onPressed: () {
                      DatePicker.showDatePicker(context,
                          showTitleActions: true,
                          minTime: DateTime(1980, 1, 1),
                          maxTime: DateTime(3000, 12, 31),
                          onConfirm: (date) {setState(() {
                            _selectedDate=DateFormat("yyyy-MM-dd").format(date);
                          });},
                          locale: LocaleType.en);},child: Text("Show Date picker"),
                  )
      
                ],
              )

      Time Picker component code.

      Timepickers | Date Time Picker Using Flutter
        String _selectedTime;
      Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  Text("${_selectedTime??'Selected Time'}",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18),),
                  RaisedButton(
                    onPressed: () {
                      DatePicker.showTimePicker(context,
                          showTitleActions: true,
      
                          onConfirm: (time) {setState(() {
                            _selectedTime=DateFormat("HH-mm-ss").format(time);
                          });},
                          locale: LocaleType.en);},child: Text("Show Time picker"),
                  ),
      
                ],
              )

      DateTime Picker component code.

      Datetimepicker | Date Time Picker Using Flutter
      String _selectedDateTime;
      Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  Text("${_selectedDateTime??"Selected Date and Time"}",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18),),
                  RaisedButton(
                    onPressed: () {
                      DatePicker.showDateTimePicker(context,
                          showTitleActions: true,
                          minTime: DateTime(1980, 1, 1),
                          maxTime: DateTime(3000, 12, 31),
                          onConfirm: (dateTime) {setState(() {
                            _selectedDateTime=DateFormat("yyyy-MM-dd  HH-mm-ss").format(dateTime);
                          });},
                       locale: LocaleType.en);},child: Text("Show Date Time Picker"),
                  ),
      
                ],
              )

      Language Options

      In this library, you get various language options so that you can make it easy for worldwide use. For modifying the language of the component amend just update LocaleType property.

       locale: LocaleType.en

      You can choose date / time / date&time in below languages:

      • Arabic(ar)
      • Armenian(hy)
      • Azerbaijan(az)
      • Basque(eu)
      • Bengali(bn)
      • Bulgarian(bg)
      • Catalan(cat)
      • Chinese(zh)
      • Danish(da)
      • Dutch(nl)
      • English(en)
      • French(fr)
      • German(de)
      • Indonesian(id)
      • Italian(it)
      • Japanese(jp)
      • Kazakh(kk)
      • Korean(ko)
      • Persian(fa)
      • Polish (pl)
      • Portuguese(pt)
      • Russian(ru)
      • Spanish(es)
      • Thai(th)
      • Turkish(tr)
      • Vietnamese(vi)


      Get complete code on GitHub.

      Bookmark(1)

      Please login to bookmark

      Continue with Google
      0

      Tag:date and time picker in flutter github, flutter date picker, flutter datepicker widget, flutter datetimepicker, flutter showdatepicker, year picker in flutter

      • Share:
      author avatar
      Shivam Srivastava

      Mobile Solution [email protected], Android and Flutter Dev, Dart ,Founder of @Navoki, Instructor

      Previous post

      WWDC 2020 cancel due to COVID-19
      March 16, 2020

      Next post

      Flare Animation With Flutter
      March 16, 2020

      You may also like

      everything-about-flutter-3-in-google-i-o-2022 navoki.com
      Everything about Flutter 3 in Google I/O 2022
      12 May, 2022
      Flutter-Web-CORS-Error-SOLVED-Navoki.com
      [SOLVED] Flutter Web CORS Error
      4 May, 2022
      How Video Call works in Flutter
      How Incoming Video Call Notification works in Flutter
      15 April, 2022

      Leave A Reply Cancel reply

      You must be logged in to post a comment.


      Categories

      • Android
      • Dart
      • Dart Server
      • Dart Web
      • Developers
      • Flutter
      • Flutter Desktop
      • Flutter Mobile
      • Flutter Web
      • Fuchsia
      • Go Lang
      • Technology
      • Uncategorized

      Recent Post

      • Everything-About-Flutter-3-In-Google-I-O-2022 Navoki.comEverything about Flutter 3 in Google I/O 2022
      • Flutter-Web-Cors-Error-Solved-Navoki.com[SOLVED] Flutter Web CORS Error
      • How Video Call Works In FlutterHow Incoming Video Call Notification works in Flutter

      Subscribe Now

       

      Recent Courses

      Single And Multi Selection Listview In Flutter

      Single and Multi Selection ListView in Flutter

      Go Installation And Variables

      Go Installation and Variables

      List In Dart Programming Language

      List in Dart Programming language

      Variables In Dart Programming Language

      Variables in Dart Programming language

      View All

      DON’T MISS
      FLUTTER UPDATES

      Be the first to know when our blog is published.

      flutter-mobile-mockup

      Check your inbox or spam folder to confirm your subscription.

      Contact

      •   Navoki Technologies Pvt. Ltd.
        JMD Megapolis , Sector 48, Gurugram, Haryana 122018

      Company

      • About Us
      • Blogs
      • Contact
      • Privacy policy
      • Terms & Condition

      Useful Links

      • Courses
      • Youtube
      • Dev News

      Mobile

      Click and Get started in seconds

      "Navoki" is a registered trademark of Navoki.com ® 2020–2030 Navoki Technologies Pvt Ltd.

      • Terms & Condition

      Login with your site account

      Continue with Google

      By "Sign in” above to accept Navoki’s Terms of Service & Privacy Policy.

      Not a member yet? Register now

      Register a new account

      Continue with Google

      By "Sign Up” above to accept Navoki’s Terms of Service & Privacy Policy.

      Are you a member? Login now