colorScheme.secondary

This commit is contained in:
reidha 2022-01-02 18:08:47 +08:00
parent 42d078011e
commit c557e72320
7 changed files with 19 additions and 62 deletions

View file

@ -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 ## [0.1.2] - January 2, 2022
* Update library versions, the sample and README.md * Update library versions, the sample and README.md

View file

@ -17,61 +17,7 @@ This library currently has two Widgets.
## Usage sample ## Usage sample
Please check `example` in this library for the latest version. Please check [example/lib](https://github.com/reidha/checkbox_formfield/tree/master/example/lib) in this library.
```
class TaskEditPage extends StatelessWidget {
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Sample',
),
),
body: Padding(
padding: EdgeInsets.all(16),
child: Column(
children: <Widget>[
Form(
key: _formKey,
child: Column(
children: <Widget>[
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'),
),
],
),
),
],
),
),
);
}
}
```
## Specifications ## Specifications
@ -85,7 +31,7 @@ class TaskEditPage extends StatelessWidget {
|onSaved|[FormField.onSaved](https://api.flutter.dev/flutter/widgets/FormField/onSaved.html)| |onSaved|[FormField.onSaved](https://api.flutter.dev/flutter/widgets/FormField/onSaved.html)|
|validator|[FormField.validator](https://api.flutter.dev/flutter/widgets/FormField/validator.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)| |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| |enabled|Whether the checkbox is enabled|
|dense|[CheckboxListTile.dense](https://api.flutter.dev/flutter/material/CheckboxListTile/dense.html)| |dense|[CheckboxListTile.dense](https://api.flutter.dev/flutter/material/CheckboxListTile/dense.html)|
|errorColor|Color of error message<br> Default: `Theme.errorColor` (`context` is given), `Colors.red` (otherwise)| |errorColor|Color of error message<br> 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)| |checkColor|[CheckboxListTile.checkColor](https://api.flutter.dev/flutter/material/CheckboxListTile/checkColor.html)|
|controlAffinity|[CheckboxListTile.controlAffinity](https://api.flutter.dev/flutter/material/CheckboxListTile/controlAffinity.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)| |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 ### CheckboxIconFormField
@ -102,11 +50,11 @@ class TaskEditPage extends StatelessWidget {
|context|Provide a default color to `errorColor`| |context|Provide a default color to `errorColor`|
|onSaved|[FormField.onSaved](https://api.flutter.dev/flutter/widgets/FormField/onSaved.html)| |onSaved|[FormField.onSaved](https://api.flutter.dev/flutter/widgets/FormField/onSaved.html)|
|initialValue|[FormField.initialValue](https://api.flutter.dev/flutter/widgets/FormField/initialValue.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| |enabled|Whether the checkbox is enabled|
|trueIcon|`IconData` if true <br> Default: `Icons.check`| |trueIcon|`IconData` if true <br> Default: `Icons.check`|
|falseIcon|`IconData` if false <br> Default: `Icons.check_box_outline_blank`| |falseIcon|`IconData` if false <br> Default: `Icons.check_box_outline_blank`|
|trueIconColor|`Color` if true <br> Default: `Theme.accentIconTheme.color` (if `context` is given), `Theme.iconTheme.color` (otherwise)| |trueIconColor|`Color` if true <br> Default: `Theme.colorScheme.secondary` (if `context` is given), `Theme.iconTheme.color` (otherwise)|
|falseIconColor|`Color` if false <br> Default: `Theme.iconTheme.color`| |falseIconColor|`Color` if false <br> Default: `Theme.iconTheme.color`|
|disabledColor|`Color` if disabled <br> Default: `Theme.disabledColor`| |disabledColor|`Color` if disabled <br> Default: `Theme.disabledColor`|
|padding|`padding`<br> Default: 24.0| |padding|`padding`<br> Default: 24.0|

View file

@ -58,6 +58,7 @@ Widget createScaffold(BuildContext? context) {
} }
}, },
autovalidateMode: AutovalidateMode.always, autovalidateMode: AutovalidateMode.always,
contentPadding: EdgeInsets.all(1),
), ),
CheckboxIconFormField( CheckboxIconFormField(
context: context, context: context,

View file

@ -35,7 +35,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.1.2" version: "0.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:

View file

@ -25,8 +25,7 @@ class CheckboxIconFormField extends FormField<bool> {
builder: (FormFieldState<bool> state) { builder: (FormFieldState<bool> state) {
trueIconColor ??= (context == null trueIconColor ??= (context == null
? null ? null
: Theme.of(context).accentIconTheme.color); : Theme.of(context).colorScheme.secondary);
// Plan to change to colorScheme.secondary
return Padding( return Padding(
padding: EdgeInsets.all(padding), padding: EdgeInsets.all(padding),

View file

@ -17,6 +17,8 @@ class CheckboxListTileFormField extends FormField<bool> {
Color? activeColor, Color? activeColor,
Color? checkColor, Color? checkColor,
ListTileControlAffinity controlAffinity = ListTileControlAffinity.leading, ListTileControlAffinity controlAffinity = ListTileControlAffinity.leading,
EdgeInsetsGeometry? contentPadding,
bool autofocus = false,
Widget? secondary, Widget? secondary,
}) : super( }) : super(
key: key, key: key,
@ -48,6 +50,8 @@ class CheckboxListTileFormField extends FormField<bool> {
: null, : null,
controlAffinity: controlAffinity, controlAffinity: controlAffinity,
secondary: secondary, secondary: secondary,
contentPadding: contentPadding,
autofocus: autofocus,
); );
}, },
); );

View file

@ -1,6 +1,6 @@
name: checkbox_formfield name: checkbox_formfield
description: This package contains checkbox widgets that can be used as FormField for Flutter beginners. 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/ homepage: https://reidha.github.io/
repository: https://github.com/reidha/checkbox_formfield repository: https://github.com/reidha/checkbox_formfield