Added a few properties to make the field more flexible#1
Open
sarbogast wants to merge 4 commits into
Open
Conversation
jczhong
requested changes
Mar 28, 2020
| @@ -1,2 +1,3 @@ | |||
| org.gradle.jvmargs=-Xmx1536M | |||
|
|
|||
| android.enableR8=true | |||
Owner
There was a problem hiding this comment.
Please don't include irrelevant files.
| version: "3.5.0" | ||
| sdks: | ||
| dart: ">=2.2.2 <3.0.0" | ||
| dart: ">=2.4.0 <3.0.0" |
Owner
There was a problem hiding this comment.
It's my mistake that I didn't add this file into .gitignore. It should not be include in repository.
| /// So if current value is not null, then selection interface will start with | ||
| /// current value, otherwise it will look at initialSelectionValue, and if | ||
| /// this is null, then it will start with DateTime.now() | ||
| final DateTime initialSelectionValue; |
Owner
There was a problem hiding this comment.
What's the differences between initialSelectionValue and intialValue? You can use initialValue instead of adding a new parameter.
|
|
||
| /// Text that appears in the form field when the value is null, default is | ||
| /// 'Please pick a date/time' | ||
| final String nullText; |
| ), | ||
| child: Text(formatter.format(state.value)), | ||
| child: Text( | ||
| state.value != null ? formatter.format(state.value) : nullText), |
Owner
There was a problem hiding this comment.
I suggest add nullText to InputDecoration's hintText parameter.
| date = await showDatePicker( | ||
| context: context, | ||
| initialDate: state.value, | ||
| initialDate: state.value ?? initialSelectionValue, |
| version: "3.5.0" | ||
| sdks: | ||
| dart: ">=2.2.2 <3.0.0" | ||
| dart: ">=2.4.0 <3.0.0" |
Owner
|
@sarbogast Hi Sarbogast, thank you so much for your great work! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first thing that bothered me was that
use24hFormatwas hard-coded tofalse, even ifDateFormatwas 24-hour based. So that led to situations where time could be represented as 13:30 in the text field, but the date picker on iOS looked like 1:30 PM. So I exposed ause24hFormatproperty on the field itself so that the date picker can be adapted on iOS.Another thing that bothered me was that I could not use the field as is in situations where the field value could be
null, because if I set theinitialValuetonull, then it was replaced by DateTime.now().So I changed that.
Now the default value for
initialValueisnull.As a result, I added a
nullTextproperty to specify the text that appears in the text field when value isnull.And I also added a
DateTimeproperty calledinitialSelectionValueto specify which date the date picker or the date picker dialog should start with when the current value isnull.And last but not least I added a
clearableproperty that, when true, adds a suffix button to the text field to reset the value tonull.