Updating documentatino

This commit is contained in:
Gaspard Merten 2020-03-01 23:41:41 +01:00
parent 4f27d54cc6
commit c3898a8c57
3 changed files with 42 additions and 25 deletions

View file

@ -8,3 +8,6 @@
* Updating package description * Updating package description
* Formatting with DartFM * Formatting with DartFM
## 0.1.0
* Updating documentation!

View file

@ -2,8 +2,19 @@ import 'dart:io';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
/// A [FormField] that contains a [DateField].
///
/// This is a convenience widget that wraps a [DateField] widget in a
/// [FormField].
///
/// A [Form] ancestor is not required. The [Form] simply makes it easier to
/// save, reset, or validate multiple fields at once. To use without a [Form],
/// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to
/// save or reset the form field.
class DateFormField extends StatelessWidget { class DateFormField extends StatelessWidget {
/// An optional method to call with the final value when the form is saved via /// An optional method to call with the final value when the form is saved via
/// [FormState.save]. /// [FormState.save].
@ -49,17 +60,17 @@ class DateFormField extends StatelessWidget {
const DateFormField( const DateFormField(
{Key key, {Key key,
this.onSaved, this.onSaved,
this.validator, this.validator,
this.initialValue, this.initialValue,
this.autovalidate = false, this.autovalidate = false,
this.enabled = true, this.enabled = true,
this.firstDate, this.firstDate,
this.lastDate, this.lastDate,
this.label = 'Select date', this.label = 'Select date',
this.dateFormat, this.dateFormat,
this.decoration, this.decoration,
this.initialDatePickerMode}) this.initialDatePickerMode})
: super(key: key); : super(key: key);
@override @override
@ -92,7 +103,7 @@ class DateFormField extends StatelessWidget {
/// [DateField] /// [DateField]
/// ///
/// Shows an [_InputDropdown] that'll trigger [DateField._selectDate] whenever the user /// Shows an [_InputDropdown] that'll trigger [DateField._selectDate] whenever the user
/// clicks on it ! /// clicks on it ! The date picker is **platform responsive** (ios date picker style for ios, ...)
class DateField extends StatelessWidget { class DateField extends StatelessWidget {
/// Default constructor /// Default constructor
DateField({ DateField({
@ -136,6 +147,8 @@ class DateField extends StatelessWidget {
/// Shows a dialog asking the user to pick a date ! /// Shows a dialog asking the user to pick a date !
Future<void> _selectDate(BuildContext context) async { Future<void> _selectDate(BuildContext context) async {
TextFormField();
if (!Platform.isIOS) { if (!Platform.isIOS) {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
@ -195,12 +208,12 @@ class DateField extends StatelessWidget {
class _InputDropdown extends StatelessWidget { class _InputDropdown extends StatelessWidget {
const _InputDropdown( const _InputDropdown(
{Key key, {Key key,
this.label, this.label,
this.text, this.text,
this.decoration, this.decoration,
this.textStyle, this.textStyle,
this.onPressed, this.onPressed,
this.errorText}) this.errorText})
: super(key: key); : super(key: key);
/// The label to display for the field (default is 'Select date') /// The label to display for the field (default is 'Select date')
@ -223,6 +236,8 @@ class _InputDropdown extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(text != null);
BorderRadius inkwellBorderRadius; BorderRadius inkwellBorderRadius;
if (decoration?.border?.runtimeType == OutlineInputBorder) { if (decoration?.border?.runtimeType == OutlineInputBorder) {
@ -235,12 +250,11 @@ class _InputDropdown extends StatelessWidget {
borderRadius: inkwellBorderRadius, borderRadius: inkwellBorderRadius,
onTap: onPressed, onTap: onPressed,
child: InputDecorator( child: InputDecorator(
decoration: decoration ?? decoration: decoration ?? InputDecoration(
InputDecoration( labelText: label,
labelText: label, errorText: errorText,
errorText: errorText, border: UnderlineInputBorder(borderSide: BorderSide()),
border: UnderlineInputBorder(borderSide: BorderSide()), contentPadding: EdgeInsets.only(bottom: 2.0)),
contentPadding: EdgeInsets.only(bottom: 2.0)),
baseStyle: textStyle, baseStyle: textStyle,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,

View file

@ -1,6 +1,6 @@
name: date_field name: date_field
description: Contains DateField and DateFormField which allows the user to pick a DateTime from an input field! description: Contains DateField and DateFormField which allows the user to pick a DateTime from an input field!
version: 0.0.2 version: 0.1.0
homepage: 'https://github.com/GaspardMerten/date_field' homepage: 'https://github.com/GaspardMerten/date_field'
environment: environment: