add decoration option for datetime input fields

This commit is contained in:
joonsv 2023-01-05 11:15:16 +01:00
parent 5afec94105
commit 2d67da8408
5 changed files with 18 additions and 8 deletions

View file

@ -5,3 +5,7 @@
## 1.0.0 ## 1.0.0
* enforce 24h clock in the time picker because it can caused a bug on web * enforce 24h clock in the time picker because it can caused a bug on web
## 1.0.1
* add decoration option for datetime input fields

View file

@ -61,6 +61,7 @@ class _MyHomePageState extends State<MyHomePage> {
Container(height: 50), Container(height: 50),
const Text('FlutterFormInputDateTime'), const Text('FlutterFormInputDateTime'),
FlutterFormInputDateTime( FlutterFormInputDateTime(
decoration: const InputDecoration(label: Text('test')),
inputType: FlutterFormDateTimeType.time, inputType: FlutterFormDateTimeType.time,
dateFormat: DateFormat('HH:mm'), dateFormat: DateFormat('HH:mm'),
onChanged: (v) { onChanged: (v) {

View file

@ -16,6 +16,7 @@ enum FlutterFormDateTimeType {
class FlutterFormInputDateTime extends ConsumerWidget { class FlutterFormInputDateTime extends ConsumerWidget {
const FlutterFormInputDateTime({ const FlutterFormInputDateTime({
this.decoration,
Key? key, Key? key,
this.label, this.label,
this.showIcon = true, this.showIcon = true,
@ -33,7 +34,7 @@ class FlutterFormInputDateTime extends ConsumerWidget {
}) : super( }) : super(
key: key, key: key,
); );
final InputDecoration? decoration;
final Widget? label; final Widget? label;
final bool showIcon; final bool showIcon;
final FlutterFormDateTimeType inputType; final FlutterFormDateTimeType inputType;
@ -51,6 +52,7 @@ class FlutterFormInputDateTime extends ConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
return DateTimeInputField( return DateTimeInputField(
decoration: decoration,
label: label, label: label,
icon: icon, icon: icon,
firstDate: firstDate, firstDate: firstDate,

View file

@ -11,6 +11,7 @@ import 'package:intl/intl.dart';
class DateTimeInputField extends ConsumerStatefulWidget { class DateTimeInputField extends ConsumerStatefulWidget {
const DateTimeInputField({ const DateTimeInputField({
this.decoration,
Key? key, Key? key,
required this.inputType, required this.inputType,
this.label, this.label,
@ -28,6 +29,7 @@ class DateTimeInputField extends ConsumerStatefulWidget {
}) : super( }) : super(
key: key, key: key,
); );
final InputDecoration? decoration;
final FlutterFormDateTimeType inputType; final FlutterFormDateTimeType inputType;
final DateFormat dateFormat; final DateFormat dateFormat;
final bool showIcon; final bool showIcon;
@ -149,11 +151,12 @@ class _DateInputFieldState extends ConsumerState<DateTimeInputField> {
}); });
}, },
validator: (value) => widget.validator?.call(value), validator: (value) => widget.validator?.call(value),
decoration: InputDecoration( decoration: widget.decoration ??
suffixIcon: widget.showIcon ? Icon(widget.icon) : null, InputDecoration(
focusColor: Theme.of(context).primaryColor, suffixIcon: widget.showIcon ? Icon(widget.icon) : null,
label: widget.label ?? const Text("Date"), focusColor: Theme.of(context).primaryColor,
), label: widget.label ?? const Text("Date"),
),
); );
} }
} }

View file

@ -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: 1.0.0 version: 1.0.1
repository: https://github.com/Iconica-Development/flutter_input_library repository: https://github.com/Iconica-Development/flutter_input_library
environment: environment: