mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-12-28 05:34:41 +00:00
Refactor to eliminate duplicate DateFormat creation
Co-authored-by: LucasXu0 <11863087+LucasXu0@users.noreply.github.com>
This commit is contained in:
parent
7b4025108e
commit
7ae906273a
@ -239,19 +239,16 @@ class _DateTimeTextFieldState extends State<DateTimeTextField> {
|
||||
|
||||
// If the string includes time, try to parse with the combined format
|
||||
if (widget.includeTime && widget.timeFormat != null) {
|
||||
final combinedFormat = DateFormat(
|
||||
"${widget.dateFormat.pattern} ${widget.timeFormat!.pattern}",
|
||||
);
|
||||
try {
|
||||
final combinedFormat = DateFormat(
|
||||
"${widget.dateFormat.pattern} ${widget.timeFormat!.pattern}",
|
||||
);
|
||||
final result = combinedFormat.parseStrict(trimmedString);
|
||||
if (!result.isBefore(kFirstDay) && !result.isAfter(kLastDay)) {
|
||||
return result;
|
||||
}
|
||||
} catch (_) {
|
||||
try {
|
||||
final combinedFormat = DateFormat(
|
||||
"${widget.dateFormat.pattern} ${widget.timeFormat!.pattern}",
|
||||
);
|
||||
final result = combinedFormat.parse(trimmedString);
|
||||
if (!result.isBefore(kFirstDay) && !result.isAfter(kLastDay)) {
|
||||
return result;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user