EP.30 Date and Time Picker Using Flutter



Today we build a date and time picker using date_time_picker library and Flutter

Source Code

import 'package:flutter/material.dart';
import 'package:date_time_picker/date_time_picker.dart';

class DateTimePickerReel extends StatelessWidget {
  const DateTimePickerReel({Key? key}) : super(key: key);

  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.orange,
      body: Container(
        decoration: const BoxDecoration(
            image: DecorationImage(
                fit: BoxFit.cover,
                image: NetworkImage(
        alignment: Alignment.topCenter,
        padding: const EdgeInsets.symmetric(horizontal: 25),
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 10),
          margin: const EdgeInsets.only(top: 120),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(10),
          child: DateTimePicker(
            showCursor: false,
            type: DateTimePickerType.dateTimeSeparate,
            dateMask: 'd MMM, yyyy',
            initialValue: DateTime.now().toString(),
            firstDate: DateTime(2010),
            lastDate: DateTime(2050),
            icon: const Icon(Icons.event),
            dateLabelText: 'Date',
            timeLabelText: "Hour",
            onChanged: (value) => print(value),
            onSaved: (value) => print(value),

Follow to become a programming expert:

Subscribe to stackedList

Get the latest updates & blog posts right to your inbox

Articles you might like…