No description
Find a file
Steve Schalkhauser d3474da603
Merge pull request #1 from totem-technologies/update/time_initial_option
support for providing a different initial time mode
2022-11-29 20:10:39 -08:00
example Fixing initialDate behaviour 2022-03-07 10:56:37 +01:00
lib support for providing a different initial time mode 2022-11-29 20:09:40 -08: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 Adding click pointer for desktop and web 2022-11-09 12:46:06 +01:00
LICENSE Updating readme.md 2020-03-01 23:29:41 +01:00
pubspec.yaml Adding click pointer for desktop and web 2022-11-09 12:46:06 +01:00
README.md Chore: Bump Readme Version 2022-02-28 13:14:35 +10:00

date_field

pub package

Contains DateTimeField and DateTimeFormField which allows the user to pick a DateTime from an input field! Depending on the mode, it can ask the user the time, the date or both at the same time ;) !

Usage

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  date_field: ^3.0.0

In your library add the following import:

import 'package:date_field/date_field.dart';

Getting Started

There are two widgets in this package:

  • DateTimeField
  • DateTimeFormField

It follows the usual Flutter patterns convention, meaning the DateTimeFormField extends the FormField widget and wraps a DateTimeField widget.

You can customize both of these widgets with the decoration argument which is fully supported.

You can also specify whether you would like to ask the user for a date, a time or both using the mode parameter.

Example

The following picture illustrates some things you can do with this package.

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 check the GitHub repo for a complete example.