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
|
## 2.1.0
|
||||||
* make compatible with flutter 3.10
|
* 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: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "2.0.0"
|
version: "2.2.0"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -84,7 +84,8 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Future<String> getInputFromUser(FlutterFormDateTimeType inputType) async {
|
Future<String> getInputFromUser(FlutterFormDateTimeType inputType,
|
||||||
|
[DateFormat? dateFormat]) async {
|
||||||
String userInput = '';
|
String userInput = '';
|
||||||
switch (inputType) {
|
switch (inputType) {
|
||||||
case FlutterFormDateTimeType.date:
|
case FlutterFormDateTimeType.date:
|
||||||
|
@ -106,7 +107,9 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
await getInputFromUser(FlutterFormDateTimeType.time);
|
await getInputFromUser(FlutterFormDateTimeType.time);
|
||||||
if (secondInput != '') {
|
if (secondInput != '') {
|
||||||
var date = widget.dateFormat.parse(value);
|
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');
|
.parse('01 01 1970 $secondInput');
|
||||||
userInput = widget.dateFormat.format(DateTime(
|
userInput = widget.dateFormat.format(DateTime(
|
||||||
date.year,
|
date.year,
|
||||||
|
@ -161,7 +164,10 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
initialValue: currentValue.isEmpty ? widget.initialValue : currentValue,
|
initialValue: currentValue.isEmpty ? widget.initialValue : currentValue,
|
||||||
onSaved: (value) => widget.onSaved?.call(value),
|
onSaved: (value) => widget.onSaved?.call(value),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
String userInput = await getInputFromUser(widget.inputType);
|
String userInput = await getInputFromUser(
|
||||||
|
widget.inputType,
|
||||||
|
DateFormat('dd MM yyyy HH:mm'),
|
||||||
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
currentValue = userInput != '' ? userInput : currentValue;
|
currentValue = userInput != '' ? userInput : currentValue;
|
||||||
widget.onChanged?.call(userInput != '' ? userInput : currentValue);
|
widget.onChanged?.call(userInput != '' ? userInput : currentValue);
|
||||||
|
|
|
@ -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.1.1
|
version: 2.2.0
|
||||||
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