2023-12-16 17:53:50 +00:00
_**Forked from https://github.com/GaspardMerten/date_field**_
2023-04-12 08:16:47 +00:00
# Welcome to the Date Field package! 📅
2020-03-01 22:16:29 +00:00
2023-04-12 08:16:47 +00:00
[![pub package ](https://img.shields.io/pub/v/date_field.svg )](https://pub.dev/packages/date_field)
2021-01-22 18:38:04 +00:00
2023-04-12 08:16:47 +00:00
This package provides two widgets, DateTimeField and DateTimeFormField, which allow users to pick a date and/or time from an input field. You can customize the appearance of the widgets using the decoration argument, and specify whether to ask for a date, a time, or both using the mode parameter.
2021-01-22 18:38:04 +00:00
2023-04-12 08:16:47 +00:00
## Here's how to get started 🚀
2020-03-01 22:16:29 +00:00
2023-04-12 08:16:47 +00:00
Add the date_field package to your project's dependencies in pubspec.yaml.
2021-01-22 18:38:04 +00:00
```yaml
dependencies:
...
2023-04-12 15:00:42 +00:00
date_field: ^3.0.5
2021-01-22 18:38:04 +00:00
```
2020-03-01 22:16:29 +00:00
2023-04-12 08:16:47 +00:00
Import the package in your Dart code.
2020-03-01 22:29:41 +00:00
2021-01-22 18:38:04 +00:00
```dart
import 'package:date_field/date_field.dart';
```
2023-04-12 08:16:47 +00:00
Use the DateTimeField or DateTimeFormField widget in your code, and customize it using the available parameters.
## Available Parameters 📝
- < b > onSaved</ b > : a callback that is called when the form is saved.
- < b > validator</ b > : a callback that is called to validate the value.
- < b > initialValue</ b > : the initial value of the field.
- < b > autovalidateMode</ b > : when to validate the field.
- < b > enabled</ b > : whether the field is enabled or disabled.
- < b > use24hFormat</ b > : whether to use a 24-hour format for the time picker.
- < b > dateTextStyle</ b > : the text style for the date.
- < b > dateFormat</ b > : the format of the date.
- < b > firstDate</ b > : the earliest date that can be selected.
- < b > lastDate</ b > : the latest date that can be selected.
- < b > initialDate</ b > : the initial date that is selected.
- < b > onDateSelected</ b > : a callback that is called when a date is selected.
- < b > decoration</ b > : the decoration for the field.
- < b > initialEntryMode</ b > : the initial entry mode of the date picker.
- < b > initialDatePickerMode</ b > : the initial date picker mode.
- < b > mode</ b > : the mode of the date and time picker.
- < b > initialTimePickerEntryMode</ b > : the initial entry mode of the time picker.
- < b > fieldCreator</ b > : the creator of the DateTimeField.
## Example Usage 📖
Here's an example usage of < b > DateTimeFormField< / b > :
2021-01-22 18:38:04 +00:00
2023-04-12 08:16:47 +00:00
```dart
2021-01-22 18:38:04 +00:00
DateTimeFormField(
decoration: const InputDecoration(
hintStyle: TextStyle(color: Colors.black45),
errorStyle: TextStyle(color: Colors.redAccent),
border: OutlineInputBorder(),
suffixIcon: Icon(Icons.event_note),
labelText: 'Only time',
),
mode: DateTimeFieldPickerMode.time,
autovalidateMode: AutovalidateMode.always,
validator: (e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null,
onDateSelected: (DateTime value) {
print(value);
},
2023-04-12 08:16:47 +00:00
)
2021-01-22 18:38:04 +00:00
```
2020-07-19 14:53:45 +00:00
2023-04-12 08:16:47 +00:00
You can find more examples and a complete example on the GitHub repository. We hope this package is helpful to you!
## License 📜
This package is released under the MIT license.
## Contributing 🤝
Contributions to this package are welcome! If you find a bug or have a feature request, please create an issue on the GitHub repository. If you'd like to contribute code, please create a pull request with your changes.
Before submitting a pull request, please make sure to run the tests and ensure they all pass. Additionally, please follow the existing coding style and make sure your code is well-documented.
2023-12-16 17:53:50 +00:00
Thank you for your contributions!