A day night time picker for Flutter. Beautiful day and night animation with Sun and Moon assets.

Overview

DayNightTimePicker

All Contributors

A day night time picker for Flutter with Zero Dependencies.

Default style:



IOS style:



View it on pub.dev


Installation

Add to pubspec.yaml.

dependencies:
  day_night_time_picker:

Usage

To use plugin, just import package

import 'package:day_night_time_picker/day_night_time_picker.dart';

Example

FlatButton(
    onPressed: () {
        Navigator.of(context).push(
            showPicker(
                context: context,
                value: _time,
                onChange: onTimeChanged,
            ),
        );
    },
    child: Text(
        "Open time picker",
        style: TextStyle(color: Colors.white),
    ),
),

Props

Name Description Default
value Required Display value. It takes in [TimeOfDay].
onChange Required Return the new time the user picked as [TimeOfDay].
onChangeDateTime Optional Return the new time the user picked as [DateTime].
is24HrFormat Show the time in TimePicker in 24 hour format. false
accentColor Accent color of the TimePicker. Theme.of(context).accentColor
unselectedColor Color applied unselected options (am/pm, hour/minute). Colors.grey
cancelText Text displayed for the Cancel button. cancel
okText Text displayed for the Ok button. ok
sunAsset Image asset used for the Sun. Asset provided
moonAsset Image asset used for the Moon. Asset provided
blurredBackground Whether to blur the background of the [Modal]. false
barrierColor Color of the background of the [Modal]. Colors.black45
borderRadius Border radius of the [Container] in [double]. 10.0
elevation Elevation of the [Modal] in [double]. 12.0
dialogInsetPadding Inset padding of the [Modal] in EdgeInsets. EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0)
barrierDismissible Whether clicking outside should dismiss the [Modal]. true
iosStylePicker Whether to display a IOS style picker (Not exactly the same). false
hourLabel The label to be displayed for hour picker. Only for iosStylePicker. 'hours'
minuteLabel The label to be displayed for minute picker. Only for iosStylePicker. 'minutes'
minuteInterval Steps interval while changing minute. Accepts MinuteInterval enum. MinuteInterval.ONE
disableMinute Disables the minute picker. false
disableHour Disables the hour picker. false
minHour Selectable minimum hour. Defaults to 1[12hr] or 0[24hr]
maxHour Selectable maximum hour. Defaults to 12[12hr] or 23[24hr]
minMinute Selectable minimum minute. 0
maxMinute Selectable maximum minute. 59
displayHeader Whether to display the sun moon animation. true
isOnValueChangeMode Weather to hide okText, cancelText and return value on every onValueChange. Only for Inline widget false
focusMinutePicker Whether or not the minute picker is auto focus/selected. false
themeData ThemeData to use for the widget. Theme.of(context)
okStyle Ok button's text style. const TextStyle(fontWeight: FontWeight.bold)
cancelStyle Cancel button's text style. const TextStyle(fontWeight: FontWeight.bold)

Notes

To render an inline widget, use the method: createInlinePicker(). It accepts the same props.


Contributors

Thanks goes to these wonderful people:


Subhamay Dutta

πŸ’» πŸ“–

Andrew Zuo

πŸ’»

Mohammad Odeh

πŸ’»

Hashem Alayan

πŸ’»

gohdong

πŸ’»

nohli

πŸ’»

sander102907

πŸ’»

Sobhan Moradi

🎨

Omar Dahhane

πŸ’»

Fatih Yaman

🎨

JerryShen

πŸ’»

本倚ε₯也

πŸ’»

Tempelritter

πŸ’»

Silfalion

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!


LICENCE

Copyright 2020 Subhamay Dutta

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Half screen goes black when clicking on showPicker

    Half screen goes black when clicking on showPicker

    the screen goes half black when using the showPicker() method i am using GetX state management and i used the same example in the Pub.dev page

    onTap: () async {
    
                                        Navigator.of(context).push(
                showPicker(
                    context: context,
                    value: managerController.initialSelectedVacStartTime,
                    onChange: null,
                ),
            );
    
                                      },
    

    Simulator-Screen-Shot-i-Phone-11-Pro-Max-2021-04-25-at-13-16-54

    help wanted 
    opened by mohadel92 10
  • Min - Max Hour for 12 Hour Format

    Min - Max Hour for 12 Hour Format

    Hi, how can I set the min max hour for the 12 hour format?

    Our timings should be 10AM to 9PM.

    I tried puttingminHour: 10 and maxHour: 21

    but it doesn't accept it using the 12 hour format.

    How can I make this work?

    bug 
    opened by rjtubera 7
  • Issue with meridiems for ios style

    Issue with meridiems for ios style

    As you can see in the video, my phone is set to 20:04, so the meridiem should continue to display p.m instead of a.m as the hour changes.

    Here is the code.

    import 'package:day_night_time_picker/day_night_time_picker.dart';
    import 'package:flutter/material.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Home(),
        );
      }
    }
    
    class Home extends StatelessWidget {
      const Home({
        Key? key,
      }) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: ElevatedButton(
              child: const Text('Open Time Picker'),
              onPressed: () {
                Navigator.of(context).push(
                  showPicker(
                    context: context,
                    value: TimeOfDay.now(),
                    iosStylePicker: true,
                    onChange: (value) {
                      print(value.toString());
                    },
                  ),
                );
              },
            ),
          ),
        );
      }
    }
    

    output

    bug 
    opened by rafoolin 6
  • RTL app direction

    RTL app direction

    OS: android OS Version: 8.0 Device: oneplus 3T

    The picked time in RTL app layout isn't display right

    instead of displaying: HH:MM (24 hours format) H:MM (12 hours format)

    it displaying: MM:HH (24 hours format) MM:H (12 hours format)

    1 2

    UPDATE: So this is my solution for this problem until it will be fixed:

    Navigator.of(context).push(
      PageRouteBuilder(
    	pageBuilder: (context, _, __) {
    	  return Directionality(
    		textDirection: TextDirection.ltr,
    		child: showPicker(
    		  value: value,
    		  onChange: onChanged,
    		  is24HrFormat: true,
    		).buildPage(context, _, __),
    	  );
    	},
    	transitionDuration: Duration(milliseconds: 200),
    	transitionsBuilder: (context, anim, secondAnim, child) => SlideTransition(
    	  position: anim.drive(
    		Tween(
    		  begin: const Offset(0, 0.15),
    		  end: const Offset(0, 0),
    		).chain(
    		  CurveTween(curve: Curves.ease),
    		),
    	  ),
    	  child: FadeTransition(
    		opacity: anim,
    		child: child,
    	  ),
    	),
    	barrierDismissible: true,
    	opaque: false,
    	barrierColor: Colors.black45,
      ),
    

    basically I just wrapped the time pick dialog with PageRouteBuilder and Directionality and I set the textDirection property to LRT. The rest of the PageRouteBuilder properties is the same of the original time pick dialog, I just copied it to maintain the same look and feel of the original dialog

    Sorry for bad english

    enhancement fixed/added 
    opened by SayWut 6
  • How to disable specific time?

    How to disable specific time?

    I want to make an appointment app.

    I want to disable time slots which are altready booked so user are unable to select it.

    For ex: if an appointment is already been made for 9:30. I want the slider to jump from 9:20 to 9:40 skipping 9:30.

    Any idea on how can i acheive this?

    question 
    opened by vivasvan1 5
  • Working on Flutter 3.0.0 but throwing this error

    Working on Flutter 3.0.0 but throwing this error

    Hello,

    Love your plugin. It is working well, however, on Flutter 3.0.0, it is throwing the following error:

    ../../.pub-cache/hosted/pub.dartlang.org/day_night_time_picker-1.0.5/lib/lib/day_night_timepicker_ios.dart:72:28: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
     - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../fvm/versions/2.5.3/packages/flutter/lib/src/widgets/binding.dart').
                WidgetsBinding.instance!.addPostFrameCallback((_) {
                               ^
    ../../.pub-cache/hosted/pub.dartlang.org/day_night_time_picker-1.0.5/lib/lib/day_night_timepicker_ios.dart:80:30: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
     - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../fvm/versions/2.5.3/packages/flutter/lib/src/widgets/binding.dart').
                  WidgetsBinding.instance!.addPostFrameCallback((_) {
                                 ^
    ../../.pub-cache/hosted/pub.dartlang.org/day_night_time_picker-1.0.5/lib/lib/day_night_timepicker_ios.dart:91:28: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
     - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../fvm/versions/2.5.3/packages/flutter/lib/src/widgets/binding.dart').
                WidgetsBinding.instance!.addPostFrameCallback((_) {
                               ^
    ../../.pub-cache/hosted/pub.dartlang.org/day_night_time_picker-1.0.5/lib/lib/day_night_timepicker_ios.dart:103:30: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
     - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../fvm/versions/2.5.3/packages/flutter/lib/src/widgets/binding.dart').
                  WidgetsBinding.instance!.addPostFrameCallback((_) {`
    ```
    
    
    opened by nialljawad96 4
  • Fix the initial hour on iOS

    Fix the initial hour on iOS

    Issue details here: https://github.com/subhamayd2/day_night_time_picker/issues/54

    Replicating the bug

    • Show time picker widget with the following values
      • iosStylePicker set to true
      • value of TimeOfDay in the P.M. time period (ie: 4 PM)
    • Swipe on the "hours" wheel -> Notice am/pm change

    Why does this happen

    Notice that when you adjust the hours, the "am" text gets selected. This is because the hour is initialized with respect to the time period (meaning, out of 12 instead of 24). However, the wheel itself has 24 options, not 12.

    How to fix this

    Simply disregrard the time period when calculating the "initial hour" for the DisplayWheel

    opened by saifb 4
  • Bottom overflow in landscape on small phones (ie 720x1480)

    Bottom overflow in landscape on small phones (ie 720x1480)

    Hi,

    I encountered an issue on small phones. When used in landscape mode the date picker popup window is too large for the screen. A RenderFlex overflow error message is shown.

    Steps to reproduce:

    1. use a virtual device with a low resolution (Galaxy Nexus or something with 720x1280 or lower)
    2. open the time picker as a popup (I used the example code)
    3. turn device to landscape

    Screenshot_1630005777

    Best regards,

    Sam

    bug enhancement fixed/added 
    opened by samflink 4
  • [Feature request] - Select minutes before

    [Feature request] - Select minutes before

    Hello. @subhamayd2 Congratulations on the component.

    Would it be possible to have some parameter (by default false so as not to affect normal behavior) that would allow first to choose the minutes before the hours?

    I am going to use the component with displayHeader:false to model the use case of choosing a duration that, in general, will always be expressed in minutes and not hours. Having the minutes preselected would help with the usability of the component.

    Regards.

    enhancement 
    opened by henry2man 4
  • add dialogInsetPadding

    add dialogInsetPadding

    I was trying to create time picker by day_night_time_picker in my app style like below image.

    Simulator Screen Shot - iPhone 12 Pro - 2021-03-11 at 14 32 36

    But I could not remove Modal padding (below image) with the available parameters and features of day_night_time_picker.

    Simulator Screen Shot - iPhone 12 Pro - 2021-03-11 at 14 32 55

    I added dialogInsetPadding to your widget for this approach.

    opened by sobimor 3
  • exception when setting minMinute and maxMinute properties to 0

    exception when setting minMinute and maxMinute properties to 0

    There is an exception when I run this code it happens when I set minMinute and maxMinute properties to 0

    showPicker(
      value: value,
      onChange: onChanged,
      is24HrFormat: is24HoursFormat,
      maxHour: 11,
      minHour: 4,
      minMinute: 0,
      maxMinute: 0,
    )
    
    ════════ Exception caught by widgets library ═══════════════════════════════════
    The following assertion was thrown building DayNightTimePickerAndroid(dirty, dependencies: [_LocalizationsScope-[GlobalKey#6d8b2], _InheritedTheme], state: _DayNightTimePickerAndroidState#919cd):
    'package:flutter/src/material/slider.dart': Failed assertion: line 167 pos 15: 'divisions == null || divisions > 0': is not true.
    
    When the exception was thrown, this was the stack
    #2      new Slider
    package:flutter/…/material/slider.dart:167
    #3      _DayNightTimePickerAndroidState.build
    package:day_night_time_picker/lib/day_night_timepicker_android.dart:335
    #4      StatefulElement.build
    package:flutter/…/widgets/framework.dart:4744
    #5      ComponentElement.performRebuild
    package:flutter/…/widgets/framework.dart:4627
    #6      StatefulElement.performRebuild
    package:flutter/…/widgets/framework.dart:4800
    ...
    ════════════════════════════════════════════════════════════════
    
    Inactivity 
    opened by SayWut 3
  • Any way to add a max width or height constraint to the popups?

    Any way to add a max width or height constraint to the popups?

    TimeOfDay time = TimeOfDay.fromDateTime(_mondayStart); Navigator.of(context).push( showPicker( context: context, value: time, onChange: (_) {}, minuteInterval: MinuteInterval.FIFTEEN, onChangeDateTime: (DateTime dateTime) { setState(() { _mondayStart = dateTime; }); }, ), );

    I would like to add a maximum width to the popup. If an app needs to adapt from mobile to web (desktop), it can look quite weird to fill up a whole desktop/laptop monitor screen. It's the right approach for mobile devices, however. I can't figure out how to put a max width constraint for large screens.

    Waiting for more info 
    opened by taufiq-husain 1
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
A DateTime picker that lets user to select a date and the time, with start & end as a range

Omni DateTime Picker A DateTime picker that lets user to select a date and the time, with start & end as a range. Screenshots Getting started Add this

null 17 Dec 29, 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
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
Beautiful Date Range Picker Dialog For Flutter

Beautiful Date Range Picker Dialog For Flutter

Mazouzi Aymene 36 Dec 22, 2022
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 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
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
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
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
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
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
A Flutter package allows you to easily implement all calendar UI and calendar event functionality. πŸ‘ŒπŸ”πŸŽ‰

calendar_view A Flutter package allows you to easily implement all calendar UI and calendar event functionality. For web demo visit Calendar View Exam

Simform Solutions 219 Dec 22, 2022
Flutter calendar app. register schedule and manage in calendar ui.

flutter calendar app. register schedule and manage in calendar ui. save schedule data in firestore. and create widget and read schedule from firestore in widget.

akiho 11 Oct 30, 2022
Fluboard - Calendar wall-board-display built with Flutter and ❀️

Fluboard Calendar wall-board-display built with Flutter and ❀️ Goals Build calendar board (DAKBoard alternative) which easy to install and easy to cus

iTeqno 10 Dec 27, 2022