A DateTime picker that lets user to select a date and the time, with start & end as a range

Overview

Omni DateTime Picker

A DateTime picker that lets user to select a date and the time, with start & end as a range.

Screenshots

Omni DateTime Picker - Light

Omni DateTime Range Picker - Dark

Getting started

Add this to your package's pubspec.yaml file and run flutter pub get:

dependencies:
  omni_datetime_picker: ^0.0.1

Now in your Dart code, you can use:

import 'package:omni_datetime_picker/omni_datetime_picker.dart';

Usage

Simple usage:

OmniDateTimePicker

DateTime? dateTime = await showOmniDateTimePicker(context: context);

OmniDateTimeRangePicker

List<DateTime>? dateTimeList = await showOmniDateTimePicker(context: context);

Custom properties:

OmniDateTimePicker

DateTime? dateTime = await showOmniDateTimePicker(
              context: context,
              primaryColor: Colors.cyan,
              backgroundColor: Colors.grey[900],
              calendarTextColor: Colors.white,
              tabTextColor: Colors.white,
              unselectedTabBackgroundColor: Colors.grey[700],
              buttonTextColor: Colors.white,
              timeSpinnerTextStyle:
                  const TextStyle(color: Colors.white70, fontSize: 18),
              timeSpinnerHighlightedTextStyle:
                  const TextStyle(color: Colors.white, fontSize: 24),
              is24HourMode: false,
              isShowSeconds: false,
              startInitialDate: DateTime.now(),
              startFirstDate:
                  DateTime(1600).subtract(const Duration(days: 3652)),
              startLastDate: DateTime.now().add(
                const Duration(days: 3652),
              ),
              borderRadius: const Radius.circular(16),
            );

OmniDateTimeRangePicker

List<DateTime>? dateTimeList = await showOmniDateTimeRangePicker(
              context: context,
              primaryColor: Colors.cyan,
              backgroundColor: Colors.grey[900],
              calendarTextColor: Colors.white,
              tabTextColor: Colors.white,
              unselectedTabBackgroundColor: Colors.grey[700],
              buttonTextColor: Colors.white,
              timeSpinnerTextStyle:
                  const TextStyle(color: Colors.white70, fontSize: 18),
              timeSpinnerHighlightedTextStyle:
                  const TextStyle(color: Colors.white, fontSize: 24),
              is24HourMode: false,
              isShowSeconds: false,
              startInitialDate: DateTime.now(),
              startFirstDate:
                  DateTime(1600).subtract(const Duration(days: 3652)),
              startLastDate: DateTime.now().add(
                const Duration(days: 3652),
              ),
              endInitialDate: DateTime.now(),
              endFirstDate: DateTime(1600).subtract(const Duration(days: 3652)),
              endLastDate: DateTime.now().add(
                const Duration(days: 3652),
              ),
              borderRadius: const Radius.circular(16),
            );

The returned value of showOmniDateTimeRangePicker() will be a List with two DateTime: [startDateTime, endDateTime].

Comments
  • Add TextField support

    Add TextField support

    hi thanks for the package, after searching a lot a date time picker and date range picker I found that you package is the best, I have a request if you can add an option to edit the date time in a form field like the native date picker they have both options it'll be amazing, because for desktop some prefer to select the date with the keyboard, thanx

    opened by hmbenhaim 3
  • OmniDateTimePicker doesn't respect the Time information in the passted intial Date

    OmniDateTimePicker doesn't respect the Time information in the passted intial Date

    Hi, thanks a lot for your package, and happy holidays!

    I find that the OmniDateTimePicker won't consider the Time information in my initial DateTime object. Here's an example:

    DateTime date = DateTime.now().toUtc().add(const Duration(hours: -11))
    
    final DateTime? dateTime = await showOmniDateTimePicker(
      context: context,
      is24HourMode: false,
      isShowSeconds: false,
      startInitialDate: date,
      startFirstDate: DateTime.now().toUtc().subtract(const Duration(days: 365)),
      startLastDate: DateTime.now().toUtc(),
      borderRadius: const Radius.circular(16),
    );
    
    

    This resulting picker will show the time as the current device time, instead of the date object's time which is 11 hours behind now.

    Also, the FirstDate and LastDate time is not respected as a cutoff time for the time spinners. Also, opening the dialog and then tapping OK without changing anything will cause the resulting DateTime to be equal to the current day and time, regardless of the initial date passed. I can produce this on Android.

    opened by KhatibFX 2
  • Not saving date and time while selecting

    Not saving date and time while selecting

    Function: DateTime? dateTime =await showOmniDateTimePicker(context: context);

    I had put this function but the problem is when i pick date and time it doesn't save on the textfield. How can i solve this?

    opened by Sarat-1997 1
  • Replace hardcoded text values by localized defaults

    Replace hardcoded text values by localized defaults

    Thank you for this well designed and lightweight library.

    In this PR, I propose we use localized default strings for the labels instead of hardcoded string values.

    The MaterialLocalizations class is also used in the official calendar_date_picker. The changes in this PR are analogous to the Google implementation.

    The "done" button text will be replaced by "save". I couldn't find a default "done" text, and I believe "save" to me more expressive anyway.

    opened by klartraum-medien 1
  • The 24-hour time selector is not centered by default

    The 24-hour time selector is not centered by default

    Hi, thanks a lot for your package; i like it.

    image

    DateTime? dateTime = await showOmniDateTimePicker(
          context: viewService.context,
          primaryColor: Colors.cyan,
          backgroundColor: Colors.grey[900],
          calendarTextColor: Colors.white,
          tabTextColor: Colors.white,
          unselectedTabBackgroundColor: Colors.grey[700],
          buttonTextColor: Colors.white,
          timeSpinnerTextStyle:
              const TextStyle(color: Colors.white70, fontSize: 18),
          timeSpinnerHighlightedTextStyle:
              const TextStyle(color: Colors.white, fontSize: 24),
          is24HourMode: true,
          isShowSeconds: false,
          startInitialDate: DateTime.parse(state.dateStr),
          startFirstDate: DateTime(1600).subtract(const Duration(days: 3652)),
          startLastDate: DateTime.now().add(
            const Duration(days: 3652),
          ),
          borderRadius: const Radius.circular(16),
        );
    

    In this mode, the time selection is not centered by default, which makes obsessive-compulsive disorder uncomfortable. Can you fix it or provide custom options, thank you very much

    image image

    opened by foraixh 1
  • DateTimePicker does not use the initial time value in the InitialDate parameter

    DateTimePicker does not use the initial time value in the InitialDate parameter

    Reproducing code:

    import 'package:flutter/material.dart';
    import 'package:intl/intl.dart';
    import 'package:omni_datetime_picker/omni_datetime_picker.dart';
    
    final DateFormat workerHistoryDateTimeFormat =
        DateFormat('dd MMMM yyyy - h:mm a');
    DateTime date = DateTime.now().toUtc().add(const Duration(hours: -11));
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatefulWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      _MyAppState createState() => _MyAppState();
    }
    
    class _MyAppState extends State<MyApp> {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Omni DateTime Picker',
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            body: Builder(builder: (context) {
              return Center(
                child: ElevatedButton(
                  onPressed: () async {
                    DateTime? dateTime = await showOmniDateTimePicker(
                      context: context,
                      is24HourMode: false,
                      isShowSeconds: false,
                      startInitialDate: date,
                      startFirstDate: DateTime.now()
                          .toUtc()
                          .subtract(const Duration(days: 365)),
                      startLastDate: DateTime.now().toUtc(),
                      borderRadius: const Radius.circular(16),
                    );
                  },
                  child: Text(workerHistoryDateTimeFormat.format(date)),
                ),
              );
            }),
          ),
        );
      }
    }
    
    

    Pubspec.yaml:

    name: omni_datetime_demo
    description: A new Flutter project.
    
    # The following line prevents the package from being accidentally published to
    # pub.dev using `flutter pub publish`. This is preferred for private packages.
    publish_to: 'none' # Remove this line if you wish to publish to pub.dev
    
    # The following defines the version and build number for your application.
    # A version number is three numbers separated by dots, like 1.2.43
    # followed by an optional build number separated by a +.
    # Both the version and the builder number may be overridden in flutter
    # build by specifying --build-name and --build-number, respectively.
    # In Android, build-name is used as versionName while build-number used as versionCode.
    # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
    # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
    # Read more about iOS versioning at
    # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.15.0 <3.0.0"
    
    # Dependencies specify other packages that your package needs in order to work.
    # To automatically upgrade your package dependencies to the latest versions
    # consider running `flutter pub upgrade --major-versions`. Alternatively,
    # dependencies can be manually updated by changing the version numbers below to
    # the latest version available on pub.dev. To see which dependencies have newer
    # versions available, run `flutter pub outdated`.
    dependencies:
      flutter:
        sdk: flutter
    
      omni_datetime_picker: ^0.0.3
      intl: ^0.17.0
    
    
      # The following adds the Cupertino Icons font to your application.
      # Use with the CupertinoIcons class for iOS style icons.
      cupertino_icons: ^1.0.2
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    
      # The "flutter_lints" package below contains a set of recommended lints to
      # encourage good coding practices. The lint set provided by the package is
      # activated in the `analysis_options.yaml` file located at the root of your
      # package. See that file for information about deactivating specific lint
      # rules and activating additional ones.
      flutter_lints: ^1.0.0
    
    # For information on the generic Dart part of this file, see the
    # following page: https://dart.dev/tools/pub/pubspec
    
    # The following section is specific to Flutter.
    flutter:
    
      # The following line ensures that the Material Icons font is
      # included with your application, so that you can use the icons in
      # the material Icons class.
      uses-material-design: true
    
      # To add assets to your application, add an assets section, like this:
      # assets:
      #   - images/a_dot_burr.jpeg
      #   - images/a_dot_ham.jpeg
    
      # An image asset can refer to one or more resolution-specific "variants", see
      # https://flutter.dev/assets-and-images/#resolution-aware.
    
      # For details regarding adding assets from package dependencies, see
      # https://flutter.dev/assets-and-images/#from-packages
    
      # To add custom fonts to your application, add a fonts section here,
      # in this "flutter" section. Each entry in this list should have a
      # "family" key with the font family name, and a "fonts" key with a
      # list giving the asset and other descriptors for the font. For
      # example:
      # fonts:
      #   - family: Schyler
      #     fonts:
      #       - asset: fonts/Schyler-Regular.ttf
      #       - asset: fonts/Schyler-Italic.ttf
      #         style: italic
      #   - family: Trajan Pro
      #     fonts:
      #       - asset: fonts/TrajanPro.ttf
      #       - asset: fonts/TrajanPro_Bold.ttf
      #         weight: 700
      #
      # For details regarding fonts from package dependencies,
      # see https://flutter.dev/custom-fonts/#from-packages
    
    

    Screenshots:

    Screenshot_20211227-190402

    Screenshot_20211227-190415

    Expected behavior:

    When clicking the button, the time showing by default will be equal to the time on the button, which is 11 hours behind, and should show in UTC as the DateTime date is set to UTC

    Actual Behavior:

    The time showing by default is equal to the current time and the current timezone.

    opened by KhatibFX 1
  • Use Custom TabView

    Use Custom TabView

    • Use custom TabView to replace the current TabView in the date_range_picker which requires infinite height and hence BoxConstraints
    • Added unselectedTabTextColor
    • References Type0N1/OmniDateTimePicker#18
    opened by dkobia 0
  • fix bindings null assertion issue with earlier flutter versions

    fix bindings null assertion issue with earlier flutter versions

    error happens when using package with earlier flutter versions

    Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
    ../…/src/time_picker_spinner.dart:219
    Try calling using ?. instead.
              .addPostFrameCallback((_) => widget.onTimeChange!(getDateTime()));
               ^^^^^^^^^^^^^^^^^^^^
    
    opened by michaelsoliman1 0
  • Fix overflow when keyboard opens

    Fix overflow when keyboard opens

    Hi. Thank you for this library.

    I added fix for flutter 3.0 and fix for #6 issue.

    Demonstration of the error: https://user-images.githubusercontent.com/65500759/170124799-66d02162-afc8-4f4b-8ab3-6711c3b55d30.mp4

    opened by Bolide9 0
Owner
null
A persian (farsi,shamsi) datetime picker for flutter, inspired by material datetime picker.

?? A persian (farsi,shamsi) datetime picker for flutter, inspired by material datetime picker. Persian datetime picker inspired by material datetime p

Persian Flutter Community 142 Dec 19, 2022
Flutter Date & Time Range Picker

F-DateTimeRangePicker Date and Time Range Picker for Flutter Installing: dependencies: f_datetimerangepicker: ^0.2.0 Using: import 'package:f_datet

Long Phan 20 Jan 18, 2022
A Custom Time Interval Select Dropdown for getting a Time Range

time_interval_picker A Custom Time Interval Select Dropdown for getting a Time R

Anurag Bansal 2 Apr 13, 2022
A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Numbers, Nepali Unicode, Nepali Moments and many more.

Nepali Utilities for Dart A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Number, Nepali

Sarbagya Dhaubanjar 23 Nov 22, 2022
Beautiful Date Range Picker Dialog For Flutter

Beautiful Date Range Picker Dialog For Flutter

Mazouzi Aymene 36 Dec 22, 2022
A flutter date time picker

Flutter Datetime Picker (Pub) flutter_datetime_picker A flutter date time picker inspired by flutter-cupertino-date-picker you can choose date / time

Realank 559 Dec 26, 2022
Allows to use date pickers without dialog. Provides some customizable styles for date pickers.

flutter_date_pickers Allows to use date pickers without dialog. Provides some customizable styles for date pickers. A set of date pickers: DayPicker f

null 196 Dec 29, 2022
A Flutter package for adding a DateRange widget into a form. A date picker UX is provided by showDateRangePicker.

A Flutter package for adding a DateRange widget into a form. A date picker UX is provided by showDateRangePicker.

JMA Consulting 9 Mar 12, 2022
Flutter Date Picker Library that provides a calendar as a horizontal timeline.

DatePickerTimeline Flutter Date Picker Library that provides a calendar as a horizontal timeline. How To Use Import the following package in your dart

LiLi 0 Oct 25, 2021
Flutter Cupertino Date Picker

Flutter Cupertino Date Picker [pub packages] | 中文说明 Flutter cupertino date picker. Usage 1. Depend Add this to you package's pubspec.yaml file: depend

Ryuuzaki 0 Nov 9, 2021
Flutter Date Picker Library that provides a calendar as a horizontal timeline

Flutter Date Picker Library that provides a calendar as a horizontal timeline.

Vivek Kaushik 214 Jan 7, 2023
⏰ Type-safe DateTime and Duration calculations, powered by extensions.

⏰ Time With shiny extensions, if you have ever written something like this, then look no further: final DateTime fourHoursFromNow = DateTime.now() + D

Jeremiah Ogbomo 467 Dec 28, 2022
A day night time picker for Flutter. Beautiful day and night animation with Sun and Moon assets.

DayNightTimePicker A day night time picker for Flutter with Zero Dependencies. Default style: IOS style: View it on pub.dev Installation Add to pubspe

Subhamay Dutta 68 Dec 29, 2022
Flutter package to create a day date scroller

scrolling_day_calendar A flutter calendar package to allow users to scroll through given dates either by swiping left and right or pressing the arrows

null 8 Jul 12, 2020
CalendarDatePicker2 - A lightweight and customizable calendar picker based on Flutter CalendarDatePicker

A lightweight and customizable calendar picker based on Flutter CalendarDatePicker, with support for single date picker, range picker and multi picker.

Neo Liu 27 Dec 22, 2022
a time planner for flutter to show task on table

A beautiful, easy to use and customizable time planner for flutter mobile ?? , desktop ?? and web ??

Mohammad Jamalianpour 150 Dec 21, 2022
A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

Amirreza Madani 63 Dec 21, 2022
Make a timer application with a fancy neon effect and beautiful UI

Make a timer application with a fancy neon effect and beautiful UI

null 6 Dec 25, 2021
Easy to use and beautiful calendar strip component for Flutter.

Flutter Calendar Strip Easy to use and beautiful calendar strip component for Flutter. Awesome celender widget If this project has helped you out, ple

Siddharth V 176 Dec 14, 2022