Formatting with dartfm

This commit is contained in:
Gaspard Merten 2020-03-01 23:34:26 +01:00
parent 14a4f9eff4
commit 4f27d54cc6
5 changed files with 40 additions and 27 deletions

View file

@ -1,3 +1,10 @@
## 0.0.1
* Initial version
## 0.0.2
* Fixing README.md
* Updating package description
* Formatting with DartFM

View file

@ -1,6 +1,6 @@
# date_field
Contains DateField and DateFormField!
Contains DateField and DateFormField which allows the user to pick a DateTime from an input field!
## Getting Started

View file

@ -8,18 +8,12 @@ void main() {
}
class ExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Example app',
home: HomeWidget()
);
return MaterialApp(title: 'Example app', home: HomeWidget());
}
}
class HomeWidget extends StatefulWidget {
@override
_HomeWidgetState createState() => _HomeWidgetState();

View file

@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class DateFormField extends StatelessWidget {
/// An optional method to call with the final value when the form is saved via
/// [FormState.save].
final FormFieldSetter<DateTime> onSaved;
@ -14,7 +13,6 @@ class DateFormField extends StatelessWidget {
/// display if the input is invalid, or null otherwise.
final FormFieldValidator<DateTime> validator;
/// An optional value to initialize the form field to, or null otherwise.
final DateTime initialValue;
@ -50,7 +48,18 @@ class DateFormField extends StatelessWidget {
final DatePickerMode initialDatePickerMode;
const DateFormField(
{Key key, this.onSaved, this.validator, this.initialValue, this.autovalidate=false, this.enabled=true, this.firstDate, this.lastDate, this.label='Select date', this.dateFormat, this.decoration, this.initialDatePickerMode})
{Key key,
this.onSaved,
this.validator,
this.initialValue,
this.autovalidate = false,
this.enabled = true,
this.firstDate,
this.lastDate,
this.label = 'Select date',
this.dateFormat,
this.decoration,
this.initialDatePickerMode})
: super(key: key);
@override
@ -75,8 +84,7 @@ class DateFormField extends StatelessWidget {
},
selectedDate: state.value,
);
}
);
});
}
}
@ -136,7 +144,8 @@ class DateField extends StatelessWidget {
height: MediaQuery.of(context).size.height / 4,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.date,
onDateTimeChanged:(DateTime dateTime) => onDateSelected(dateTime),
onDateTimeChanged: (DateTime dateTime) =>
onDateSelected(dateTime),
initialDateTime: selectedDate ?? lastDate ?? DateTime.now(),
minimumDate: firstDate,
maximumDate: lastDate,
@ -144,8 +153,7 @@ class DateField extends StatelessWidget {
);
},
);
}
else {
} else {
DateTime _selectedDate = await showDatePicker(
context: context,
initialDatePickerMode: initialDatePickerMode,
@ -153,14 +161,12 @@ class DateField extends StatelessWidget {
firstDate: firstDate ?? DateTime(1900),
lastDate: lastDate ?? DateTime(2100));
if (_selectedDate != null) {
onDateSelected(_selectedDate);
}
}
}
@override
Widget build(BuildContext context) {
String text;
@ -188,7 +194,13 @@ class DateField extends StatelessWidget {
/// user does click on it !
class _InputDropdown extends StatelessWidget {
const _InputDropdown(
{Key key, this.label, this.text, this.decoration, this.textStyle, this.onPressed, this.errorText})
{Key key,
this.label,
this.text,
this.decoration,
this.textStyle,
this.onPressed,
this.errorText})
: super(key: key);
/// The label to display for the field (default is 'Select date')
@ -223,12 +235,12 @@ class _InputDropdown extends StatelessWidget {
borderRadius: inkwellBorderRadius,
onTap: onPressed,
child: InputDecorator(
decoration: decoration ?? InputDecoration(
labelText: label,
errorText: errorText,
border: UnderlineInputBorder(borderSide: BorderSide()),
contentPadding: EdgeInsets.only(bottom: 2.0)
),
decoration: decoration ??
InputDecoration(
labelText: label,
errorText: errorText,
border: UnderlineInputBorder(borderSide: BorderSide()),
contentPadding: EdgeInsets.only(bottom: 2.0)),
baseStyle: textStyle,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,

View file

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