diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dab922..264cef7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,3 +16,6 @@ ## 1.0.4 * fix datetimepicker format and validator + +## 1.0.5 +* add style to datetime diff --git a/example/lib/main.dart b/example/lib/main.dart index 64856ff..b4edd69 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -61,18 +61,10 @@ class _MyHomePageState extends State { Container(height: 50), const Text('FlutterFormInputDateTime'), FlutterFormInputDateTime( + style: const TextStyle(color: Colors.red), decoration: const InputDecoration(label: Text('test')), - autovalidateMode: AutovalidateMode.always, - validator: (p0) { - if (p0 == null || p0.isEmpty) return null; - return DateFormat('dd/MMMM/yyyy HH:mm') - .parse(p0) - .isAfter(DateTime.now()) - ? null - : 'Date must be in the future'; - }, - inputType: FlutterFormDateTimeType.dateTime, - dateFormat: DateFormat('dd/MMMM/yyyy HH:mm'), + inputType: FlutterFormDateTimeType.time, + dateFormat: DateFormat('HH:mm'), onChanged: (v) { debugPrint('Date changed to $v'); }, diff --git a/lib/src/inputs/date_picker/date_picker.dart b/lib/src/inputs/date_picker/date_picker.dart index b12ed72..ff62626 100644 --- a/lib/src/inputs/date_picker/date_picker.dart +++ b/lib/src/inputs/date_picker/date_picker.dart @@ -17,6 +17,7 @@ enum FlutterFormDateTimeType { class FlutterFormInputDateTime extends ConsumerWidget { const FlutterFormInputDateTime( {this.decoration, + this.style, Key? key, this.label, this.showIcon = true, @@ -35,6 +36,7 @@ class FlutterFormInputDateTime extends ConsumerWidget { : super( key: key, ); + final TextStyle? style; final InputDecoration? decoration; final Widget? label; final bool showIcon; @@ -54,6 +56,7 @@ class FlutterFormInputDateTime extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return DateTimeInputField( + style: style, decoration: decoration, autovalidateMode: autovalidateMode, validator: validator, diff --git a/lib/src/inputs/date_picker/date_picker_field.dart b/lib/src/inputs/date_picker/date_picker_field.dart index ebfcd83..132c10f 100644 --- a/lib/src/inputs/date_picker/date_picker_field.dart +++ b/lib/src/inputs/date_picker/date_picker_field.dart @@ -27,9 +27,11 @@ class DateTimeInputField extends ConsumerStatefulWidget { this.onChanged, this.onSaved, this.validator, + required this.style, }) : super( key: key, ); + final TextStyle? style; final InputDecoration? decoration; final AutovalidateMode autovalidateMode; final FlutterFormDateTimeType inputType; @@ -149,6 +151,7 @@ class _DateInputFieldState extends ConsumerState { } return TextFormField( + style: widget.style, autovalidateMode: widget.autovalidateMode, keyboardType: TextInputType.none, readOnly: true, diff --git a/pubspec.yaml b/pubspec.yaml index a1cb727..d0abde0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_input_library description: A new Flutter package project. -version: 1.0.4 +version: 1.0.5 repository: https://github.com/Iconica-Development/flutter_input_library environment: