From 2d67da840870bfe7ae56d301adcfbfe25476c6fd Mon Sep 17 00:00:00 2001 From: joonsv Date: Thu, 5 Jan 2023 11:15:16 +0100 Subject: [PATCH] add decoration option for datetime input fields --- CHANGELOG.md | 6 +++++- example/lib/main.dart | 1 + lib/src/inputs/date_picker/date_picker.dart | 4 +++- lib/src/inputs/date_picker/date_picker_field.dart | 13 ++++++++----- pubspec.yaml | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d548a43..6664031 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,4 +4,8 @@ ## 1.0.0 -* enforce 24h clock in the time picker because it can caused a bug on web \ No newline at end of file +* 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 \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 51fa675..c423657 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -61,6 +61,7 @@ class _MyHomePageState extends State { Container(height: 50), const Text('FlutterFormInputDateTime'), FlutterFormInputDateTime( + decoration: const InputDecoration(label: Text('test')), inputType: FlutterFormDateTimeType.time, dateFormat: DateFormat('HH:mm'), onChanged: (v) { diff --git a/lib/src/inputs/date_picker/date_picker.dart b/lib/src/inputs/date_picker/date_picker.dart index ad533ec..e4ee2a1 100644 --- a/lib/src/inputs/date_picker/date_picker.dart +++ b/lib/src/inputs/date_picker/date_picker.dart @@ -16,6 +16,7 @@ enum FlutterFormDateTimeType { class FlutterFormInputDateTime extends ConsumerWidget { const FlutterFormInputDateTime({ + this.decoration, Key? key, this.label, this.showIcon = true, @@ -33,7 +34,7 @@ class FlutterFormInputDateTime extends ConsumerWidget { }) : super( key: key, ); - + final InputDecoration? decoration; final Widget? label; final bool showIcon; final FlutterFormDateTimeType inputType; @@ -51,6 +52,7 @@ class FlutterFormInputDateTime extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return DateTimeInputField( + decoration: decoration, label: label, icon: icon, firstDate: firstDate, diff --git a/lib/src/inputs/date_picker/date_picker_field.dart b/lib/src/inputs/date_picker/date_picker_field.dart index c9f233c..5d99b6f 100644 --- a/lib/src/inputs/date_picker/date_picker_field.dart +++ b/lib/src/inputs/date_picker/date_picker_field.dart @@ -11,6 +11,7 @@ import 'package:intl/intl.dart'; class DateTimeInputField extends ConsumerStatefulWidget { const DateTimeInputField({ + this.decoration, Key? key, required this.inputType, this.label, @@ -28,6 +29,7 @@ class DateTimeInputField extends ConsumerStatefulWidget { }) : super( key: key, ); + final InputDecoration? decoration; final FlutterFormDateTimeType inputType; final DateFormat dateFormat; final bool showIcon; @@ -149,11 +151,12 @@ class _DateInputFieldState extends ConsumerState { }); }, validator: (value) => widget.validator?.call(value), - decoration: InputDecoration( - suffixIcon: widget.showIcon ? Icon(widget.icon) : null, - focusColor: Theme.of(context).primaryColor, - label: widget.label ?? const Text("Date"), - ), + decoration: widget.decoration ?? + InputDecoration( + suffixIcon: widget.showIcon ? Icon(widget.icon) : null, + focusColor: Theme.of(context).primaryColor, + label: widget.label ?? const Text("Date"), + ), ); } } diff --git a/pubspec.yaml b/pubspec.yaml index dafd909..e3021c9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_input_library description: A new Flutter package project. -version: 1.0.0 +version: 1.0.1 repository: https://github.com/Iconica-Development/flutter_input_library environment: