From 4f27d54cc65233cdcc1b5b8afc73e044dc6aba2f Mon Sep 17 00:00:00 2001 From: Gaspard Merten Date: Sun, 1 Mar 2020 23:34:26 +0100 Subject: [PATCH] Formatting with dartfm --- CHANGELOG.md | 7 +++++++ README.md | 2 +- example/main.dart | 8 +------- lib/date_field.dart | 46 ++++++++++++++++++++++++++++----------------- pubspec.yaml | 4 ++-- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 847d60d..37979c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ ## 0.0.1 * Initial version + +## 0.0.2 + +* Fixing README.md +* Updating package description +* Formatting with DartFM + diff --git a/README.md b/README.md index e2cde38..29788ad 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/example/main.dart b/example/main.dart index dd19ffc..eae443e 100644 --- a/example/main.dart +++ b/example/main.dart @@ -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(); diff --git a/lib/date_field.dart b/lib/date_field.dart index aaf8b17..aff5f9c 100644 --- a/lib/date_field.dart +++ b/lib/date_field.dart @@ -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 onSaved; @@ -14,7 +13,6 @@ class DateFormField extends StatelessWidget { /// display if the input is invalid, or null otherwise. final FormFieldValidator 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, diff --git a/pubspec.yaml b/pubspec.yaml index 76bbab8..8c9c2a3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: