Coder Social home page Coder Social logo

jifalops / datetime_picker_formfield Goto Github PK

View Code? Open in Web Editor NEW
185.0 11.0 103.0 946 KB

A Flutter widget that wraps a TextFormField and integrates the date and/or time picker dialogs.

License: MIT License

Dart 34.79% Objective-C 0.06% Kotlin 0.19% Swift 1.73% CMake 27.11% C++ 31.27% C 2.13% HTML 2.72%

datetime_picker_formfield's Introduction

DateTimeField

A TextFormField that emits DateTimes and helps show Material, Cupertino, and other style picker dialogs.

Example

See the example tab (example/lib/main.dart) for more.

screenshot.gif

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';

// ...

class BasicDateField extends StatelessWidget {
  final format = DateFormat("yyyy-MM-dd");
  @override
  Widget build(BuildContext context) {
    return Column(children: <Widget>[
      Text('Basic date field (${format.pattern})'),
      DateTimeField(
        format: format,
        onShowPicker: (context, currentValue) {
          return showDatePicker(
              context: context,
              firstDate: DateTime(1900),
              initialDate: currentValue ?? DateTime.now(),
              lastDate: DateTime(2100));
        },
      ),
    ]);
  }
}

class BasicTimeField extends StatelessWidget {
  final format = DateFormat("HH:mm");
  @override
  Widget build(BuildContext context) {
    return Column(children: <Widget>[
      Text('Basic time field (${format.pattern})'),
      DateTimeField(
        format: format,
        onShowPicker: (context, currentValue) async {
          final time = await showTimePicker(
            context: context,
            initialTime: TimeOfDay.fromDateTime(currentValue ?? DateTime.now()),
          );
          return DateTimeField.convert(time);
        },
      ),
    ]);
  }
}

class BasicDateTimeField extends StatelessWidget {
  final format = DateFormat("yyyy-MM-dd HH:mm");
  @override
  Widget build(BuildContext context) {
    return Column(children: <Widget>[
      Text('Basic date & time field (${format.pattern})'),
      DateTimeField(
        format: format,
        onShowPicker: (context, currentValue) async {
          final date = await showDatePicker(
              context: context,
              firstDate: DateTime(1900),
              initialDate: currentValue ?? DateTime.now(),
              lastDate: DateTime(2100));
          if (date != null) {
            final time = await showTimePicker(
              context: context,
              initialTime:
                  TimeOfDay.fromDateTime(currentValue ?? DateTime.now()),
            );
            return DateTimeField.combine(date, time);
          } else {
            return currentValue;
          }
        },
      ),
    ]);
  }
}

datetime_picker_formfield's People

Contributors

agrelle avatar bawelter avatar d-silveira avatar egonsan-onmi avatar jacobaraujo7 avatar jifalops avatar kdy1 avatar kolaente avatar noordawod avatar stefangaller avatar tainanfochesatto avatar tamcy avatar wujerry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datetime_picker_formfield's Issues

onChanged not triggered after selecting date

After I select the date, the text changed, but the onChanged Event is not triggered. instead onChanged Event only triggered on focus / lost focus

DateTimePickerFormField(
dateOnly:true,
format:'d/M/y',
onChanged: (dt) => setState(() {
dtStart = dt;
_countDays();
}),
decoration:InputDecoration(
labelText:"Start Date",
icon:Icon(Icons.date_rage, size:24.0)), );

I use the 0.1.7 version

Editable in TimePickerFormField

Hi,
in last release (0.1.5) was added new feature "editable" in DatePickerFormField. It is possible add this functionality in to TimePickerFormField too?

Thanks a lot

Error: Method not found: 'DateTimePickerFormField' in flutter x v1.7.8+hotfix.4,

hi,
iam using flutter x v1.7.8+hotfix.4,
package installed : datetime_picker_formfield: ^0.4.0

DateTimePicker is undefined after upgrade flutter from 1.5 to 1.7

error: Error: Method not found: 'DateTimePickerFormField'
Error: The method 'DateTimePickerFormField' isn't defined for the class

flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale en-IN)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.35.1)
[✓] Connected device (1 available)

• No issues found!

Floating labels not working

As seen on the example the fields have floating labels, how do I achieve this? I copied the example code and its not displaying the floating label on my side.

image

Keyboard opening although editable is false

Im using plugin version 0.2.0.

I have a field where date should only picked up by picker but not the manaual input so i kept editable to false, but still when i clicked the DateTimePickrField keyboard and picker both are opening. My expectation is to open only picker but not the keyboard.

Flutter version: 1.6.3
Android: oreo.

Allow timepicker to select minutes

I see that with TimePickerFormField you can manually edit the minutes after selecting the hour, it would be nice to allow selecting both hour and minutes.
Ideally I want to disable editing so that users have to select exactly what they want.

Removing render overflow error when keyboard open - Fix not working.

The code that I believe is intended to correct this issue does not appear to work in my case.

Lines 251 to 255 are as follows:
if (MediaQuery.of(context).viewInsets.bottom > 0) { FocusScope.of(context).requestFocus(new FocusNode()); // add a delay just to be sure that keyboard is no longer visible await Future.delayed(Duration(milliseconds: 300)); }
The test on 251 always returns 0.0 in my app, I presume because the context is not available? Hence, the delay never runs and I still get the renderflex error.

If I check the value of MediaQuery.of(context).viewInsets.bottom immediately before calling DateTimePickerFormField I get a value of 205.0122, if I check it immediately before line 251 in DateTimePickerFormField the value is 0.0

Am I doing something wrong?

Validation not working

validation fails at this line

return widget.validator(_toDate(value, widget.format));

with this error:

I/BufferQueueProducer(28588): [SurfaceTexture-0-28588-0](this:0x77d05f7000,id:0,api:1,p:350,c:28588) queueBuffer: slot 0 is dropped, handle=0x77df643560
I/BufferQueueProducer(28588): [SurfaceTexture-0-28588-0](this:0x77d05f7000,id:0,api:1,p:350,c:28588) queueBuffer: fps=1.03 dur=1940.99 max=1002.44 min=938.55
I/flutter (28588): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter (28588): The following NoSuchMethodError was thrown while handling a gesture:
I/flutter (28588): The getter '_value' was called on null.
I/flutter (28588): Receiver: null
I/flutter (28588): Tried calling: _value
I/flutter (28588):
I/flutter (28588): When the exception was thrown, this was the stack:
I/flutter (28588): #0      Object.noSuchMethod  (dart:core-patch/object_patch.dart:50:5)
I/flutter (28588): #1      DateTime.difference  (dart:core-patch/date_patch.dart:201:54)
I/flutter (28588): #2      _NewEventState._buildPage.<anonymous closure>
package:beacon/pages/newEvent.dart:246
I/flutter (28588): #3      _DateTimePickerTextFormFieldState.build.<anonymous closure>
package:datetime_picker_formfield/datetime_picker_formfield.dart:300
I/flutter (28588): #4      FormFieldState._validate (package:flutter/src/widgets/form.dart)
I/flutter (28588): #5      FormFieldState.validate.<anonymous closure> 
package:flutter/…/widgets/form.dart:363
I/flutter (28588): #6      State.setState 
package:flutter/…/widgets/framework.dart:1117
I/flutter (28588): #7      FormFieldState.validate 
package:flutter/…/widgets/form.dart:362
I/flutter (28588): #8      FormState._validate 
package:flutter/…/widgets/form.dart:202
I/flutter (28588): #9      FormState.validate 
package:flutter/…/widgets/form.dart:196
I/flutter (28588): #10     _NewEventState._buildPage.<anonymous closure>
package:beacon/pages/newEvent.dart:354
I/flutter (28588): #11     _InkResponseState._handleTap 
package:flutter/…/material/ink_well.dart:511
I/flutter (28588): #12     _InkResponseState.build.<anonymous closure> 
package:flutter/…/material/ink_well.dart:566
I/flutter (28588): #13     GestureRecognizer.invokeCallback 
package:flutter/…/gestures/recognizer.dart:166
I/flutter (28588): #14     TapGestureRecognizer._checkUp 
package:flutter/…/gestures/tap.dart:240
I/flutter (28588): #15     TapGestureRecognizer.acceptGesture 
package:flutter/…/gestures/tap.dart:211
I/flutter (28588): #16     GestureArenaManager.sweep 
package:flutter/…/gestures/arena.dart:156
I/flutter (28588): #17     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent 
package:flutter/…/gestures/binding.dart:225
I/flutter (28588): #18     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent 
package:flutter/…/gestures/binding.dart:199
I/flutter (28588): #19     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent 
package:flutter/…/gestures/binding.dart:156
I/flutter (28588): #20     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue 
package:flutter/…/gestures/binding.dart:102
I/flutter (28588): #21     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket 
package:flutter/…/gestures/binding.dart:86
I/flutter (28588): #25     _invoke1  (dart:ui/hooks.dart:233:10)
I/flutter (28588): #26     _dispatchPointerDataPacket  (dart:ui/hooks.dart:154:5)
I/flutter (28588): (elided 3 frames from package dart:async)
I/flutter (28588):
I/flutter (28588): Handler: onTap
I/flutter (28588): Recognizer:
I/flutter (28588):   TapGestureRecognizer#5b0e1(debugOwner: GestureDetector, state: ready, won arena, finalPosition:
I/flutter (28588):   Offset(156.9, 628.7), sent tap down)
I/flutter (28588): ════════════════════════════════════════════════════════════════════════════════════════════════════

Double Datepicker raised when requestFocus has been called

For the version 0.1.8 when requestFocus is called from a another FormField and with editable: false configuration there are two DatePicker raised

TextFormField(
                      decoration: InputDecoration(
                        labelText: "Field 1",
                      ),
                      focusNode: _Field1FocusNode,
                      controller: _Field1Controller,
                      onEditingComplete: () => FocusScope.of(context)
                          .requestFocus(_date1FocusNode),
                    ),
                    DateTimePickerFormField(
                      inputType: InputType.date,
                      focusNode: _date1FocusNode,
                      controller: _date1Controller,
                      format: DateFormat('yyyy-MM-dd'),
                      editable: false,
                      initialDate: DateTime.utc(DateTime.now().year - 40,
                          DateTime.now().month, DateTime.now().day),
                      decoration:
                          InputDecoration(labelText: "Fecha de nacimiento"),
                    ),

Border colour, default time

Hey,

This is a great package.

I just need help with 2 things please:

  1. The Border size is not matching the default border - is there code I can add to change the colour and the thickness of the border?

  2. How do I set a default time?

Thank you

Allow datepicker to only select year

Hi,
thank you for your library. I was wondering, if it is possible to allow the library to only show a year dialog.

Thank you and keep up the nice work.
Cheers.

prevent manual text input

Hi,
just wondering if it would be best to prevent people typing in dates by hand? Or having a little logic to disable this if wanted. The former is achievable by removing parent.controller.text.isEmpty && previousValue.isEmpty. Want a pull request?

cheers,
Andy.

void inputChanged() {
    if (//parent.controller.text.isEmpty &&
        //_previousValue.isEmpty &&
       parent.focusNode.hasFocus) {
      getDateTimeInput(context).then((date) {
        parent.focusNode.unfocus();
        setState(() {
          parent.controller.text = _toString(date, parent.format);
          setValue(date);
        });
      });
    } else if (parent.resetIcon != null &&
        parent.controller.text.isEmpty == showResetIcon) {
      setState(() => showResetIcon = !showResetIcon);
      // parent.focusNode.unfocus();
    }
    _previousValue = parent.controller.text;
    if (!parent.focusNode.hasFocus) {
      setValue(_toDate(parent.controller.text, parent.format));
    }
  }

DateTimePickerFormField has no memory

If you press the field a second time (with editable=false), you would expect it shows the previous selected date & time in the popup.
It shows the previous selected date, but it doesn't show the previous selected time. (this is always 12:00)
Or how can this be done? Thx

add support for first time

I tried to use firstDate with an input of type 'time' but didn't work so is there a solution or it's not suported!

Thanks

support french

Hello, i don't find how to change langage, if it's normal, i would be possible to add a change langage like locale:fr

Editing date, keyboard apears

Hi, I get this issue, can you help?

First time I click it works perfectly
image

I select the Date and save it
image

But when i want to change the date, clicking again, the keyboard raises
image
image

Heare is my code

return DateTimePickerFormField(
      inputType: InputType.date,
      format: DateFormat('EEEE, dd/MM/yy', 'en_EN'),
      editable: true,
      decoration: InputDecoration(
        icon: Icon(Icons.today),
        labelText: 'Date',
        hintText: '${DateFormat('EEEE, dd/MM/yy').format(DateTime.now())}',
      ),
      dateOnly: true,
      onChanged: (dt) => setState(() => date = dt),
    );

Thanks

Focus behavior

Focus is behaving funny. On field focus, after leaving, the cursor stays in the field.

f

Set a value, then reset causes error and disable the input

W/IInputConnectionWrapper( 7958): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 7958): getTextBeforeCursor on inactive InputConnection
I/flutter ( 7958): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter ( 7958): The following assertion was thrown while handling a gesture:
I/flutter ( 7958): invalid text selection: TextSelection(baseOffset: 16, extentOffset: 16, affinity:
I/flutter ( 7958): TextAffinity.upstream, isDirectional: false)
I/flutter ( 7958): 
I/flutter ( 7958): When the exception was thrown, this was the stack:
I/flutter ( 7958): #0      TextEditingController.selection= (package:flutter/src/widgets/editable_text.dart:169:7)
I/flutter ( 7958): #1      EditableTextState._handleSelectionChanged (package:flutter/src/widgets/editable_text.dart:1216:23)
I/flutter ( 7958): #2      RenderEditable._handlePotentialSelectionChange (package:flutter/src/rendering/editable.dart:369:5)
I/flutter ( 7958): #3      RenderEditable.selectPositionAt (package:flutter/src/rendering/editable.dart:1416:9)
I/flutter ( 7958): #4      RenderEditable.selectPosition (package:flutter/src/rendering/editable.dart:1388:5)
I/flutter ( 7958): #5      _TextFieldState._handleSingleTapUp (package:flutter/src/material/text_field.dart:765:27)
I/flutter ( 7958): #6      _TextSelectionGestureDetectorState._handleTapUp (package:flutter/src/widgets/text_selection.dart:929:16)
I/flutter ( 7958): #7      TapGestureRecognizer._checkUp.<anonymous closure> (package:flutter/src/gestures/tap.dart:363:49)
I/flutter ( 7958): #8      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
I/flutter ( 7958): #9      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:363:11)
I/flutter ( 7958): #10     TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:312:7)
I/flutter ( 7958): #11     _TransparentTapGestureRecognizer.rejectGesture (package:flutter/src/widgets/text_selection.dart:1131:7)
I/flutter ( 7958): #12     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:159:26)
I/flutter ( 7958): #13     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
I/flutter ( 7958): #14     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
I/flutter ( 7958): #15     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
I/flutter ( 7958): #16     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
I/flutter ( 7958): #17     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
I/flutter ( 7958): #21     _invoke1 (dart:ui/hooks.dart:250:10)
I/flutter ( 7958): #22     _dispatchPointerDataPacket (dart:ui/hooks.dart:159:5)
I/flutter ( 7958): (elided 3 frames from package dart:async)
I/flutter ( 7958): 
I/flutter ( 7958): Handler: "onTapUp"
I/flutter ( 7958): Recognizer:
I/flutter ( 7958):   _TransparentTapGestureRecognizer#0db7e
I/flutter ( 7958): ════════════════════════════════════════════════════════════════════════════════════════════════════

DateTimePickerFormField overflow on small screens

I am currently running this on a small screen as I am running integration tests on their CI and it's running on an emulator with a small screen (size not confirmed) so I thought I would pick a small screen for a local emulator and then ran the tests and I got the issues with the DateTimePickerFormField. See image of it running on 4 WVGA (Nexus S) API 28 emulator

DateTimePickerFormField(
                  editable: false,
                  key: Key("deadline-selector"),
                  validator: (field) {
                    if (field == _createJobController.startDate || field == null) {
                      return "You must enter a future project deadline";
                    } else {
                      return null;
                    }
                  },
                  decoration: InputDecoration(hintText: "Tap to enter project deadline"),
                  initialDate: _createJobController.startDate,
                  firstDate: _createJobController.startDate.add(Duration(days: -1)),
                  dateOnly: true,
                  format: DateFormat("d MMMM yyyy"),
                  onSaved: (newDate) => _createJobController.deadline = newDate)

screenshot_1548944703

Double Datepicker raised

DateTimePickerFormField(
firstDate: DateTime.now(),
inputType: InputType.date,
format: DateFormat('dd-MM-yyyy'),
editable: false,
validator: (DateTime value) {
if (value == null) {
return 'Data obbligatoria';
} else {
widget.orderDate = value;
}
},
decoration:
InputDecoration(labelText: 'Data *', hasFloatingPlaceholder: false),
);

this is raised two or many times at open.

Focus Manager - Concurrent Modification Exception

When showing the picker there is a concurrent modification exception thrown every time. My best guess is the Text field and datepicker are trying to get the focus when the user clicks on the text field.

datetime_picker_formfield: ^0.4.0

Flutter (Channel beta, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale en-US)
• Flutter version 1.7.8+hotfix.4 at /Users/saltechsystems/flutter
• Framework revision 20e59316b8 (4 days ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0

E/flutter ( 9546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Concurrent modification during iteration: Instance of '_CompactLinkedHashSet<FocusNode>'.
E/flutter ( 9546): #0      _CompactIterator.moveNext (dart:collection-patch/compact_hash.dart:443:7)
E/flutter ( 9546): #1      FocusManager._applyFocusChange (package:flutter/src/widgets/focus_manager.dart:1056:28)
E/flutter ( 9546): #2      _rootRun (dart:async/zone.dart:1120:38)
E/flutter ( 9546): #3      _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 9546): #4      _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter ( 9546): #5      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
E/flutter ( 9546): #6      _rootRun (dart:async/zone.dart:1124:13)
E/flutter ( 9546): #7      _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 9546): #8      _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter ( 9546): #9      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
E/flutter ( 9546): #10     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 9546): #11     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

hour and minute not focus automatically after selecting date

When I select date not focusing me automatically to select hours and when i select hour datetime-picker not focusing me automatically in minute selection. To do that I have to prees button every time but I want to do that automatically. Now how could i do this, please help me.
Thank you.

issue with just library imported

hello, I have this issues instead of I have no code, just import the library , I can't launch app.

Compiler message:
file:///C:/Users/utilisateur/flutter/.pub-cache/hosted/pub.dartlang.org/datetime_picker_formfield-0.3.1/lib/datetime_picker_formfield.dart:60:17: Error: No named parameter with the name 'readOnly'.
                readOnly: child.readOnly,
                ^^^^^^^^
file:///C:/Users/utilisateur/flutter/packages/flutter/lib/src/material/text_form_field.dart:73:3: Context: Found this candidate, but the arguments don't match.
  TextFormField({
  ^
file:///C:/Users/utilisateur/flutter/.pub-cache/hosted/pub.dartlang.org/datetime_picker_formfield-0.3.1/lib/datetime_picker_formfield.dart:242:60: Error: The getter 'readOnly' isn't defined for the class 'TextField'.
 - 'TextField' is from 'package:flutter/src/material/text_field.dart' ('file:///C:/Users/utilisateur/flutter/packages/flutter/lib/src/material/text_field.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readOnly'.
    if (hasFocus && !hadFocus && (!hasText || widget.child.readOnly)) {
                                                           ^^^^^^^^

The widget stops to work once there is some text in it.

							DateTimePickerFormField(
								format: _fmt,
								focusNode: _nodes[3],
								decoration: textFieldDecorator('Pick a date'),
								validator: (v) => v == null ? 'Plase pick a date.' : null,
								onSaved: (v) => _user.birthDate = _fmt.format(v),
								initialDate: _user.birthDate == null ? null : _fmt.parse(_user.birthDate),
								lastDate: DateTime.now().add(new Duration(hours: 1)),
								onFieldSubmitted: (_) {
									_nodes[3].unfocus();
									FocusScope.of(context).requestFocus(_nodes[4]);
								},
								dateOnly: true,
								resetIcon: null,
							),

This is how I use it. It works as long as there is no text in the field. Any input makes it no longer to work.

Disable Future date values

Is there a property to disable future dates? For example today is August 20, 2018, then the DateTime picker should grayed out the date 21, 22, 23, 24.... etc. Same thing when choosing Month.

Add seconds selector in time picker

I have a requirement in my project to select exact time with seconds too. But I couldn't find out any pickers which could select seconds.

overflow error when keyboard open

[✓] Flutter (Channel master, v1.5.9-pre.108, on Mac OS X 10.13.6 17G5019, locale en-TH)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.3)
[✓] VS Code (version 1.33.1)
[✓] Connected device (1 available)

Channel master, v1.5.9-pre.108
BEB454C1-29FE-4352-8AFD-1943CF44444B

Setting "initialValue" causes year to be reset to 1970 when tapping on form field.

As the title says, if I set 'initialValue' to any DateTime object, it resets the year of said DateTime object to 1970, as soon as the formfield is tapped. It does display the correct date before the field is tapped.

The DateTimePicker is opened on the changed value, and the onChanged listeners also gets the 'update'.

My code:

DateTimePickerFormField(
            format: DateFormat("EEEE',' d MMMM"),
            initialDate: initialDate,
            initialValue: initialDate,
            inputType: InputType.date,
            editable: false,
            decoration: InputDecoration(
              contentPadding: EdgeInsets.all(2.0),
              labelText: 'Datum',
              icon: Icon(Icons.date_range)
            ),
            onChanged: (DateTime value){
              if(value != null && value.isAfter(DateTime.now().subtract(Duration(days: 3)))){
                formData["date"] = DateFormat("yyyy-MM-dd").format(value);
              }
            },
          ),

If I remove initialValue: initialDate everything works fine. (Except for the fact that there is no initialValue, obviously).

editable: false not working as expected

I've created two fields (code bellow) and I set editable to false the first field is working as expected while the second one after I click on the clear(X) button becoms editable and dosn't trigger datetime picker any more!

Padding(
    padding: EdgeInsets.all(8.0),
    child: DateTimePickerFormField(
    editable: false,
    firstDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day - 1),
    lastDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day + 2),
    format: dateFormat,
    style: TextStyle(
        fontFamily: "WorkSansSemiBold",
        fontSize: 16.0,
        color: Colors.black),
    decoration: InputDecoration(
        prefixIcon: Icon(Icons.timer),
        labelText: 'Start Time',
        hintStyle: TextStyle(
            fontFamily: "WorkSansSemiBold", fontSize: 17.0),
        border: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.black))),
    onChanged: (dt) => setState(() => startAt = dt),
    ),
),
Padding(
    padding: EdgeInsets.all(8.0),
    child: DateTimePickerFormField(
    editable: false,
    initialValue: DateTime(
        DateTime.now().year,
        DateTime.now().month,
        DateTime.now().day,
        DateTime.now().hour,
        DateTime.now().minute + 5),
    firstDate: DateTime(
        DateTime.now().year,
        DateTime.now().month,
        DateTime.now().day,
        DateTime.now().hour,
        DateTime.now().minute + 5),
    lastDate: DateTime(DateTime.now().year, DateTime.now().month,
        DateTime.now().day + 2),
    format: dateFormat,
    style: TextStyle(
        fontFamily: "WorkSansSemiBold",
        fontSize: 16.0,
        color: Colors.black),
    decoration: InputDecoration(
        prefixIcon: Icon(Icons.timer),
        labelText: 'End Time',
        hintStyle: TextStyle(
            fontFamily: "WorkSansSemiBold", fontSize: 17.0),
        border: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.black))),
    onChanged: (dt) => setState(() => endAt = dt),
    ),
),

Clearing form field

Clearing form field doesn't trigger onChanged so if setting a value there it sticks. Should onChanged be triggered for clearing form field or is there another way to clear value?

Styling colors

Hey Jifalops,

I'm using your plugin. But because i have themedata with all the colors in my main, the colors in the datetime picker are white just like the background. Now i would love to style it to my own use, i would like to have the numbers show black without using a materialapp because that will destroy my back button.

Thanks in advance,
Greetings,
J

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.