No description
Find a file
2024-05-26 16:46:53 +02:00
example Updating readme 2023-04-12 10:16:47 +02:00
lib Add controller support 2023-12-16 18:52:38 +01:00
.gitignore Chore: Remove pubspec.lock from repo 2022-02-26 11:27:04 +10:00
.metadata Init commit 2020-03-01 23:16:40 +01:00
analysis_options.yaml Fixing label & hint style issues 2021-09-22 20:06:57 +02:00
CHANGELOG.md fixes #42 dense empty form field 2023-08-17 17:01:44 +02:00
LICENSE Updating readme.md 2020-03-01 23:29:41 +01:00
pubspec.yaml Bump versions 2024-05-26 16:46:53 +02:00
README.md Update README 2023-12-16 18:53:50 +01:00

Forked from https://github.com/GaspardMerten/date_field

Welcome to the Date Field package! 📅

pub package

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.

Here's how to get started 🚀

Add the date_field package to your project's dependencies in pubspec.yaml.

dependencies:
  ...
  date_field: ^3.0.5

Import the package in your Dart code.

import 'package:date_field/date_field.dart';

Use the DateTimeField or DateTimeFormField widget in your code, and customize it using the available parameters.

Available Parameters 📝

  • onSaved: a callback that is called when the form is saved.
  • validator: a callback that is called to validate the value.
  • initialValue: the initial value of the field.
  • autovalidateMode: when to validate the field.
  • enabled: whether the field is enabled or disabled.
  • use24hFormat: whether to use a 24-hour format for the time picker.
  • dateTextStyle: the text style for the date.
  • dateFormat: the format of the date.
  • firstDate: the earliest date that can be selected.
  • lastDate: the latest date that can be selected.
  • initialDate: the initial date that is selected.
  • onDateSelected: a callback that is called when a date is selected.
  • decoration: the decoration for the field.
  • initialEntryMode: the initial entry mode of the date picker.
  • initialDatePickerMode: the initial date picker mode.
  • mode: the mode of the date and time picker.
  • initialTimePickerEntryMode: the initial entry mode of the time picker.
  • fieldCreator: the creator of the DateTimeField.

Example Usage 📖

Here's an example usage of DateTimeFormField:

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);
  },
)

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.

Thank you for your contributions!