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
|
* make compatible with flutter 3.10
|
||||||
|
|
||||||
## 2.2.0
|
## 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: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "2.2.0"
|
version: "2.2.1"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -26,6 +26,7 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
||||||
this.lastDate,
|
this.lastDate,
|
||||||
this.initialDate,
|
this.initialDate,
|
||||||
this.initialDateTimeRange,
|
this.initialDateTimeRange,
|
||||||
|
this.initialTime,
|
||||||
this.icon = Icons.calendar_today,
|
this.icon = Icons.calendar_today,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
@ -44,6 +45,7 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
||||||
final DateFormat dateFormat;
|
final DateFormat dateFormat;
|
||||||
final DateTime? initialDate;
|
final DateTime? initialDate;
|
||||||
final DateTimeRange? initialDateTimeRange;
|
final DateTimeRange? initialDateTimeRange;
|
||||||
|
final TimeOfDay? initialTime;
|
||||||
final DateTime? firstDate;
|
final DateTime? firstDate;
|
||||||
final DateTime? lastDate;
|
final DateTime? lastDate;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
@ -69,6 +71,7 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
||||||
dateFormat: dateFormat,
|
dateFormat: dateFormat,
|
||||||
initialDate: initialDate,
|
initialDate: initialDate,
|
||||||
initialDateTimeRange: initialDateTimeRange,
|
initialDateTimeRange: initialDateTimeRange,
|
||||||
|
initialTime: initialTime,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
onChanged: (value) => onChanged?.call(value),
|
onChanged: (value) => onChanged?.call(value),
|
||||||
onSaved: (value) => onSaved?.call(value),
|
onSaved: (value) => onSaved?.call(value),
|
||||||
|
|
|
@ -21,6 +21,7 @@ class DateTimeInputField extends StatefulWidget {
|
||||||
required this.firstDate,
|
required this.firstDate,
|
||||||
required this.lastDate,
|
required this.lastDate,
|
||||||
this.initialDate,
|
this.initialDate,
|
||||||
|
this.initialTime,
|
||||||
this.initialDateTimeRange,
|
this.initialDateTimeRange,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
|
@ -40,6 +41,7 @@ class DateTimeInputField extends StatefulWidget {
|
||||||
final DateTime? firstDate;
|
final DateTime? firstDate;
|
||||||
final DateTime? lastDate;
|
final DateTime? lastDate;
|
||||||
final DateTime? initialDate;
|
final DateTime? initialDate;
|
||||||
|
final TimeOfDay? initialTime;
|
||||||
final DateTimeRange? initialDateTimeRange;
|
final DateTimeRange? initialDateTimeRange;
|
||||||
final IconData? icon;
|
final IconData? icon;
|
||||||
final Widget? label;
|
final Widget? label;
|
||||||
|
@ -58,6 +60,7 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
late final DateTime lastDate;
|
late final DateTime lastDate;
|
||||||
late final DateTime initialDate;
|
late final DateTime initialDate;
|
||||||
late final DateTimeRange initialDateRange;
|
late final DateTimeRange initialDateRange;
|
||||||
|
late final TimeOfDay? initialTime;
|
||||||
String currentValue = '';
|
String currentValue = '';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -82,6 +85,8 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TimeOfDay get initialTimeOfDay => widget.initialTime ?? TimeOfDay.now();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Future<String> getInputFromUser(FlutterFormDateTimeType inputType,
|
Future<String> getInputFromUser(FlutterFormDateTimeType inputType,
|
||||||
|
@ -137,20 +142,20 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
break;
|
break;
|
||||||
case FlutterFormDateTimeType.time:
|
case FlutterFormDateTimeType.time:
|
||||||
userInput = await showTimePicker(
|
userInput = await showTimePicker(
|
||||||
initialEntryMode: widget.timePickerEntryMode,
|
initialEntryMode: widget.timePickerEntryMode,
|
||||||
builder: (BuildContext context, Widget? child) {
|
builder: (BuildContext context, Widget? child) {
|
||||||
return MediaQuery(
|
return MediaQuery(
|
||||||
data: MediaQuery.of(context)
|
data: MediaQuery.of(context)
|
||||||
.copyWith(alwaysUse24HourFormat: true),
|
.copyWith(alwaysUse24HourFormat: true),
|
||||||
child: child!,
|
child: child!,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
context: context,
|
context: context,
|
||||||
initialTime: TimeOfDay.now())
|
initialTime: initialTimeOfDay,
|
||||||
.then((value) => value == null
|
).then((value) => value == null
|
||||||
? ''
|
? ''
|
||||||
: MaterialLocalizations.of(context)
|
: MaterialLocalizations.of(context)
|
||||||
.formatTimeOfDay(value, alwaysUse24HourFormat: true));
|
.formatTimeOfDay(value, alwaysUse24HourFormat: true));
|
||||||
}
|
}
|
||||||
return userInput;
|
return userInput;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_input_library
|
name: flutter_input_library
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 2.2.0
|
version: 2.2.1
|
||||||
repository: https://github.com/Iconica-Development/flutter_input_library
|
repository: https://github.com/Iconica-Development/flutter_input_library
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue