mirror of
https://github.com/Iconica-Development/flutter_input_library.git
synced 2025-05-18 17:03:45 +02:00
Merge pull request #19 from Iconica-Development/2.2.1
fix: initial time is optional
This commit is contained in:
commit
2f0ceff64e
5 changed files with 28 additions and 17 deletions
|
@ -30,4 +30,7 @@
|
|||
* make compatible with flutter 3.10
|
||||
|
||||
## 2.2.0
|
||||
* Dateformat optional on input from the user, defaulting to 24 hour format
|
||||
* Dateformat optional on input from the user, defaulting to 24 hour format
|
||||
|
||||
## 2.2.1
|
||||
* Initial time optional on input from the user, defaulting to current time
|
|
@ -68,7 +68,7 @@ packages:
|
|||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "2.2.0"
|
||||
version: "2.2.1"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
|
|
@ -26,6 +26,7 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
|||
this.lastDate,
|
||||
this.initialDate,
|
||||
this.initialDateTimeRange,
|
||||
this.initialTime,
|
||||
this.icon = Icons.calendar_today,
|
||||
this.initialValue,
|
||||
this.onChanged,
|
||||
|
@ -44,6 +45,7 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
|||
final DateFormat dateFormat;
|
||||
final DateTime? initialDate;
|
||||
final DateTimeRange? initialDateTimeRange;
|
||||
final TimeOfDay? initialTime;
|
||||
final DateTime? firstDate;
|
||||
final DateTime? lastDate;
|
||||
final IconData icon;
|
||||
|
@ -69,6 +71,7 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
|||
dateFormat: dateFormat,
|
||||
initialDate: initialDate,
|
||||
initialDateTimeRange: initialDateTimeRange,
|
||||
initialTime: initialTime,
|
||||
initialValue: initialValue,
|
||||
onChanged: (value) => onChanged?.call(value),
|
||||
onSaved: (value) => onSaved?.call(value),
|
||||
|
|
|
@ -21,6 +21,7 @@ class DateTimeInputField extends StatefulWidget {
|
|||
required this.firstDate,
|
||||
required this.lastDate,
|
||||
this.initialDate,
|
||||
this.initialTime,
|
||||
this.initialDateTimeRange,
|
||||
this.initialValue,
|
||||
this.onChanged,
|
||||
|
@ -40,6 +41,7 @@ class DateTimeInputField extends StatefulWidget {
|
|||
final DateTime? firstDate;
|
||||
final DateTime? lastDate;
|
||||
final DateTime? initialDate;
|
||||
final TimeOfDay? initialTime;
|
||||
final DateTimeRange? initialDateTimeRange;
|
||||
final IconData? icon;
|
||||
final Widget? label;
|
||||
|
@ -58,6 +60,7 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
|||
late final DateTime lastDate;
|
||||
late final DateTime initialDate;
|
||||
late final DateTimeRange initialDateRange;
|
||||
late final TimeOfDay? initialTime;
|
||||
String currentValue = '';
|
||||
|
||||
@override
|
||||
|
@ -82,6 +85,8 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
|||
super.initState();
|
||||
}
|
||||
|
||||
TimeOfDay get initialTimeOfDay => widget.initialTime ?? TimeOfDay.now();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Future<String> getInputFromUser(FlutterFormDateTimeType inputType,
|
||||
|
@ -137,20 +142,20 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
|||
break;
|
||||
case FlutterFormDateTimeType.time:
|
||||
userInput = await showTimePicker(
|
||||
initialEntryMode: widget.timePickerEntryMode,
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context)
|
||||
.copyWith(alwaysUse24HourFormat: true),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now())
|
||||
.then((value) => value == null
|
||||
? ''
|
||||
: MaterialLocalizations.of(context)
|
||||
.formatTimeOfDay(value, alwaysUse24HourFormat: true));
|
||||
initialEntryMode: widget.timePickerEntryMode,
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context)
|
||||
.copyWith(alwaysUse24HourFormat: true),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
context: context,
|
||||
initialTime: initialTimeOfDay,
|
||||
).then((value) => value == null
|
||||
? ''
|
||||
: MaterialLocalizations.of(context)
|
||||
.formatTimeOfDay(value, alwaysUse24HourFormat: true));
|
||||
}
|
||||
return userInput;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_input_library
|
||||
description: A new Flutter package project.
|
||||
version: 2.2.0
|
||||
version: 2.2.1
|
||||
repository: https://github.com/Iconica-Development/flutter_input_library
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Reference in a new issue