Closed galenwarren closed 3 months ago
I don't think this is something the package should allow. It could cause bugs to open implementation details as _handleTap
. Also I think it is not a good UX to open a dialog without tapping on the form field.
If you really need this, you can copy the widget code to your project and modify it to your needs. The License allows that
You don't think it would be viable UX where someone would click on a button and then be prompted to provide a date? Say, for example, a clocking in/out app for time management. Obviously, some sort of input event needs to occur to prompt the dialog to show but not sure why that only makes sense in terms of clicking on a form field as opposed to some other element.
I'm also not sure I'm following regarding exposing implementation details -- what would be exposed?
I'll use my fork if you're not interested in this enhancement, but I figured others might run into the same issue. Thanks.
Sure, clicking a button and opening a dialog is a viable UX. But this package provides a widget that is supposed to be used as a form field. And opening the dialog that is filling the form field without tapping on the form field is not good UX in my opinion.
And opening the dialog that is filling the form field without tapping on the form field is not good UX in my opinion
Just to be clear, there would be no visible form field to tap on in this flow. Agreed that if there were a form field in view, it would be odd to bring the popup up through some other mechanism.
This library has a nice UI for date and time, better than others I tried -- it would be nice to use it in a broader range of circumstances. But, if that's not the way you want to go, that's fine.
@torbenkeller, it could be extract the "show date time picker" to a public method, it would lighten the field.dart file while offering a better separation of concerns...
Like this, the package could offer a showAdaptiveDateTimePicker method?
What do you think? (I will implement it myself, no worries ;)).
@GaspardMerten That would be perfect for my use case -- thanks!
@galenwarren, could you review the PR to see if it suits your needs?
@GaspardMerten Yes I will give it a look this week, thanks!
It has now been released in v5.2.0
@GaspardMerten Sorry it took me so long to take a look, I've been really busy. I just pulled down the latest and it works great! Thanks.
I was running Flutter 3.19 and it doesn't work in that environment, because of the renaming of MaterialState to WidgetState in the core flutter library (breaking change). Worked fine once I upgraded to 3.22. Just mentioning that in case anyone else runs into the same thing.
Again, thanks for adding this support! Really appreciate it.
It would be helpful to be able to show the picker via code instead of just via a tap. My particular use case is that I want to show a pop-up to get a date without requiring the user to see and tap on a field.
This could be done easily by changing
_DateTimeFieldState
toDateTimeFieldState
and then exposing the_handleTap
method, perhaps asshowPicker
. Then, one could pass in aGlobalKey<DateTimeFieldState>
to an instance ofDateTimeField
and invoke it that way. For convenience, we could also make that method return the selected value.I'd be happy to submit a PR for this if you're interested. Thanks.