From c557e7232003776f4b2b6ab51db9273d07c42bd1 Mon Sep 17 00:00:00 2001 From: reidha Date: Sun, 2 Jan 2022 18:08:47 +0800 Subject: [PATCH] colorScheme.secondary --- CHANGELOG.md | 5 +++ README.md | 64 +++------------------------ example/lib/main.dart | 1 + example/pubspec.lock | 2 +- lib/checkbox_icon_formfield.dart | 3 +- lib/checkbox_list_tile_formfield.dart | 4 ++ pubspec.yaml | 2 +- 7 files changed, 19 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 632c27d..8d08ce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.2.0] - January 2, 2022 - BREAKING CHANGE! + +* [CheckboxIconFormfield] Replace `accentIconTheme.color` with `colorScheme.secondary` as `accentIconTheme.color` is deprecated +* [CheckboxListTileFormfield] Add `contentPadding` and `autofocus` + ## [0.1.2] - January 2, 2022 * Update library versions, the sample and README.md diff --git a/README.md b/README.md index c842182..916c27f 100644 --- a/README.md +++ b/README.md @@ -17,61 +17,7 @@ This library currently has two Widgets. ## Usage sample -Please check `example` in this library for the latest version. - -``` -class TaskEditPage extends StatelessWidget { - final _formKey = GlobalKey(); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text( - 'Sample', - ), - ), - body: Padding( - padding: EdgeInsets.all(16), - child: Column( - children: [ - Form( - key: _formKey, - child: Column( - children: [ - CheckboxListTileFormField( - title: Text('Check!'), - onSaved: (bool value) {}, - validator: (bool value) { - if (value) { - return null; - } else { - return 'False!'; - } - }, - ), - CheckboxIconFormField( - iconSize: 32, - onSaved: (bool value) {}, - ), - RaisedButton( - onPressed: () { - if (_formKey.currentState.validate()) { - _formKey.currentState.save(); - } - }, - child: Text('Submit'), - ), - ], - ), - ), - ], - ), - ), - ); - } -} -``` +Please check [example/lib](https://github.com/reidha/checkbox_formfield/tree/master/example/lib) in this library. ## Specifications @@ -85,7 +31,7 @@ class TaskEditPage extends StatelessWidget { |onSaved|[FormField.onSaved](https://api.flutter.dev/flutter/widgets/FormField/onSaved.html)| |validator|[FormField.validator](https://api.flutter.dev/flutter/widgets/FormField/validator.html)| |initialValue|[FormField.initialValue](https://api.flutter.dev/flutter/widgets/FormField/initialValue.html)| -|autovalidate|[FormField.autovalidateMode](https://api.flutter.dev/flutter/widgets/FormField/autovalidateMode.html)| +|autovalidateMode|[FormField.autovalidateMode](https://api.flutter.dev/flutter/widgets/FormField/autovalidateMode.html)| |enabled|Whether the checkbox is enabled| |dense|[CheckboxListTile.dense](https://api.flutter.dev/flutter/material/CheckboxListTile/dense.html)| |errorColor|Color of error message
Default: `Theme.errorColor` (`context` is given), `Colors.red` (otherwise)| @@ -93,6 +39,8 @@ class TaskEditPage extends StatelessWidget { |checkColor|[CheckboxListTile.checkColor](https://api.flutter.dev/flutter/material/CheckboxListTile/checkColor.html)| |controlAffinity|[CheckboxListTile.controlAffinity](https://api.flutter.dev/flutter/material/CheckboxListTile/controlAffinity.html)| |secondary|[CheckboxListTile.secondary](https://api.flutter.dev/flutter/material/CheckboxListTile/secondary.html)| +|contentPadding|[CheckboxListTile.contentPadding](https://api.flutter.dev/flutter/material/CheckboxListTile/contentPadding.html)| +|autofocus|[CheckboxListTile.autofocus](https://api.flutter.dev/flutter/material/CheckboxListTile/autofocus.html)| ### CheckboxIconFormField @@ -102,11 +50,11 @@ class TaskEditPage extends StatelessWidget { |context|Provide a default color to `errorColor`| |onSaved|[FormField.onSaved](https://api.flutter.dev/flutter/widgets/FormField/onSaved.html)| |initialValue|[FormField.initialValue](https://api.flutter.dev/flutter/widgets/FormField/initialValue.html)| -|autovalidate|[FormField.autovalidateMode](https://api.flutter.dev/flutter/widgets/FormField/autovalidateMode.html)| +|autovalidateMode|[FormField.autovalidateMode](https://api.flutter.dev/flutter/widgets/FormField/autovalidateMode.html)| |enabled|Whether the checkbox is enabled| |trueIcon|`IconData` if true
Default: `Icons.check`| |falseIcon|`IconData` if false
Default: `Icons.check_box_outline_blank`| -|trueIconColor|`Color` if true
Default: `Theme.accentIconTheme.color` (if `context` is given), `Theme.iconTheme.color` (otherwise)| +|trueIconColor|`Color` if true
Default: `Theme.colorScheme.secondary` (if `context` is given), `Theme.iconTheme.color` (otherwise)| |falseIconColor|`Color` if false
Default: `Theme.iconTheme.color`| |disabledColor|`Color` if disabled
Default: `Theme.disabledColor`| |padding|`padding`
Default: 24.0| diff --git a/example/lib/main.dart b/example/lib/main.dart index eabda8f..56fee62 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -58,6 +58,7 @@ Widget createScaffold(BuildContext? context) { } }, autovalidateMode: AutovalidateMode.always, + contentPadding: EdgeInsets.all(1), ), CheckboxIconFormField( context: context, diff --git a/example/pubspec.lock b/example/pubspec.lock index ec26188..31829a4 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -35,7 +35,7 @@ packages: path: ".." relative: true source: path - version: "0.1.2" + version: "0.2.0" clock: dependency: transitive description: diff --git a/lib/checkbox_icon_formfield.dart b/lib/checkbox_icon_formfield.dart index e739d5a..919fe84 100644 --- a/lib/checkbox_icon_formfield.dart +++ b/lib/checkbox_icon_formfield.dart @@ -25,8 +25,7 @@ class CheckboxIconFormField extends FormField { builder: (FormFieldState state) { trueIconColor ??= (context == null ? null - : Theme.of(context).accentIconTheme.color); - // Plan to change to colorScheme.secondary + : Theme.of(context).colorScheme.secondary); return Padding( padding: EdgeInsets.all(padding), diff --git a/lib/checkbox_list_tile_formfield.dart b/lib/checkbox_list_tile_formfield.dart index ff3e0ca..56afec1 100644 --- a/lib/checkbox_list_tile_formfield.dart +++ b/lib/checkbox_list_tile_formfield.dart @@ -17,6 +17,8 @@ class CheckboxListTileFormField extends FormField { Color? activeColor, Color? checkColor, ListTileControlAffinity controlAffinity = ListTileControlAffinity.leading, + EdgeInsetsGeometry? contentPadding, + bool autofocus = false, Widget? secondary, }) : super( key: key, @@ -48,6 +50,8 @@ class CheckboxListTileFormField extends FormField { : null, controlAffinity: controlAffinity, secondary: secondary, + contentPadding: contentPadding, + autofocus: autofocus, ); }, ); diff --git a/pubspec.yaml b/pubspec.yaml index ef20676..11aa471 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: checkbox_formfield description: This package contains checkbox widgets that can be used as FormField for Flutter beginners. -version: 0.1.2 +version: 0.2.0 homepage: https://reidha.github.io/ repository: https://github.com/reidha/checkbox_formfield