checkbox_formfield 0.1.0+3

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

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 #

ParameterDescription
keyFormField.key
titleCheckboxListTile.title
contextProvide a default color to errorColor
onSavedFormField.onSaved
validatorFormField.validator
initialValueFormField.initialValue
autovalidateFormField.autovalidate
enabledWhether the checkbox is enabled
denseCheckboxListTile.dense
errorColorColor of error message
Default: Theme.errorColor (context is given), Colors.red (otherwise)
activeColorCheckboxListTile.activeColor
checkColorCheckboxListTile.checkColor
controlAffinityCheckboxListTile.controlAffinity
secondaryCheckboxListTile.secondary

CheckboxIconFormField #

ParameterDescription
keyFormField.key
contextProvide a default color to errorColor
onSavedFormField.onSaved
initialValueFormField.initialValue
autovalidateFormField.autovalidate
enabledWhether the checkbox is enabled
trueIconIconData if true
Default: Icons.check
falseIconIconData if false
Default: Icons.check_box_outline_blank
trueIconColorColor if true
Default: Theme.accentIconTheme.color (if context is given), Theme.iconTheme.color (otherwise)
falseIconColorColor if false
Default: Theme.iconTheme.color
disabledColorColor if disabled
Default: Theme.disabledColor
paddingpadding
Default: 24.0
iconSizeIcon.size

[0.1.0+3] - April 22, 2020 #

  • Update description
  • Fix typo: checkbox_list tile_formfield.dart --> checkbox_list_tile_formfield.dart

[0.1.0+2] - April 22, 2020 #

  • Update description

[0.1.0+1] - April 12, 2020 #

  • Add example directory

[0.1.0] - April 12, 2020 #

  • Big fix: CheckboxIconFormField.enabled was not working
  • Default colors can be set by providing context properly
  • Update README.md

[0.0.1] - April 12, 2020 #

  • Add CheckboxListTileFormField
  • Add CheckboxIconFormField

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:checkbox_formfield/checkbox_formfield.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Simple Lightweight Todo',
      theme: ThemeData(
        primarySwatch: Colors.indigo,
        accentColor: Colors.blue,
        disabledColor: Colors.purple,
        accentIconTheme: IconThemeData(
          color: Colors.blue,
        ),
      ),
      home: createScaffold(),
    );
  }
}

Widget createScaffold() {
  final _formKey = GlobalKey<FormState>();
  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) {
                    print(value);
                  },
                  validator: (bool value) {
                    if (value) {
                      return null;
                    } else {
                      return 'False!';
                    }
                  },
                ),
                CheckboxIconFormField(
                  initialValue: true,
                  enabled: false,
                  iconSize: 32,
                  onSaved: (bool value) {},
                ),
                RaisedButton(
                  onPressed: () {
                    if (_formKey.currentState.validate()) {
                      _formKey.currentState.save();
                    }
                  },
                  child: Text('New'),
                ),
              ],
            ),
          ),
        ],
      ),
    ),
  );
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  checkbox_formfield: ^0.1.0+3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:checkbox_formfield/checkbox_formfield.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
71
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • checkbox_formfield that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test