mirror of
https://github.com/Iconica-Development/flutter_input_library.git
synced 2025-05-18 17:03:45 +02:00
fix: 12 o'clock at noon selectable
This commit is contained in:
parent
a0afa5e401
commit
b349078cf7
4 changed files with 15 additions and 7 deletions
|
@ -29,3 +29,5 @@
|
|||
## 2.1.0
|
||||
* make compatible with flutter 3.10
|
||||
|
||||
## 2.2.0
|
||||
* Dateformat optional on input from the user, defaulting to 24 hour format
|
|
@ -68,7 +68,7 @@ packages:
|
|||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "2.0.0"
|
||||
version: "2.2.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
|
|
@ -84,7 +84,8 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Future<String> getInputFromUser(FlutterFormDateTimeType inputType) async {
|
||||
Future<String> getInputFromUser(FlutterFormDateTimeType inputType,
|
||||
[DateFormat? dateFormat]) async {
|
||||
String userInput = '';
|
||||
switch (inputType) {
|
||||
case FlutterFormDateTimeType.date:
|
||||
|
@ -106,7 +107,9 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
|||
await getInputFromUser(FlutterFormDateTimeType.time);
|
||||
if (secondInput != '') {
|
||||
var date = widget.dateFormat.parse(value);
|
||||
var time = DateFormat('dd MM yyyy hh:mm')
|
||||
var time = dateFormat != null
|
||||
? dateFormat.parse('01 01 1970 $secondInput')
|
||||
: DateFormat('dd MM yyyy HH:mm')
|
||||
.parse('01 01 1970 $secondInput');
|
||||
userInput = widget.dateFormat.format(DateTime(
|
||||
date.year,
|
||||
|
@ -161,7 +164,10 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
|||
initialValue: currentValue.isEmpty ? widget.initialValue : currentValue,
|
||||
onSaved: (value) => widget.onSaved?.call(value),
|
||||
onTap: () async {
|
||||
String userInput = await getInputFromUser(widget.inputType);
|
||||
String userInput = await getInputFromUser(
|
||||
widget.inputType,
|
||||
DateFormat('dd MM yyyy HH:mm'),
|
||||
);
|
||||
setState(() {
|
||||
currentValue = userInput != '' ? userInput : currentValue;
|
||||
widget.onChanged?.call(userInput != '' ? userInput : currentValue);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_input_library
|
||||
description: A new Flutter package project.
|
||||
version: 2.1.1
|
||||
version: 2.2.0
|
||||
repository: https://github.com/Iconica-Development/flutter_input_library
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Reference in a new issue