No description
Find a file
2021-12-05 23:41:38 +08:00
example Add onChanged callback 2021-11-14 20:03:25 +01:00
lib Merge branch 'master' into OnChanged_missing 2021-11-28 21:14:38 +08:00
.gitignore 0.0.1: Initial commit 2020-04-12 17:31:19 +07:00
.metadata 0.0.1: Initial commit 2020-04-12 17:31:19 +07:00
CHANGELOG.md changed description 2021-12-05 23:19:00 +08:00
LICENSE Initial commit 2020-04-12 15:54:03 +07:00
pubspec.lock Migrate to null-safety 2021-08-17 13:48:08 +02:00
pubspec.yaml update pubspec.yaml 2021-12-05 23:36:24 +08:00
README.md Update README.md 2020-04-12 21:09:05 +07:00

checkbox_formfield

pub package

A few kinds of checkbox that can be used as FormField

Getting Started

This library currently has two Widgets.

  • CheckboxListTileFormField: Use CheckboxListTile in Form
  • CheckboxIconFormField: Use two Icons as if they consist a checkbox and also in Form

Demo

Demo

Usage sample

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

CheckboxListTileFormField

Parameter Description
key FormField.key
title CheckboxListTile.title
context Provide a default color to errorColor
onSaved FormField.onSaved
validator FormField.validator
initialValue FormField.initialValue
autovalidate FormField.autovalidate
enabled Whether the checkbox is enabled
dense CheckboxListTile.dense
errorColor Color of error message
Default: Theme.errorColor (context is given), Colors.red (otherwise)
activeColor CheckboxListTile.activeColor
checkColor CheckboxListTile.checkColor
controlAffinity CheckboxListTile.controlAffinity
secondary CheckboxListTile.secondary

CheckboxIconFormField

Parameter Description
key FormField.key
context Provide a default color to errorColor
onSaved FormField.onSaved
initialValue FormField.initialValue
autovalidate FormField.autovalidate
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)
falseIconColor Color if false
Default: Theme.iconTheme.color
disabledColor Color if disabled
Default: Theme.disabledColor
padding padding
Default: 24.0
iconSize Icon.size