parent
97570ff2f9
commit
106f2d6bbb
7 changed files with 98 additions and 182 deletions
|
@ -3,19 +3,19 @@ import 'package:flutter/material.dart';
|
|||
/// Use Icon as checkbox
|
||||
class CheckboxIconFormField extends FormField<bool> {
|
||||
CheckboxIconFormField({
|
||||
Key key,
|
||||
BuildContext context,
|
||||
FormFieldSetter<bool> onSaved,
|
||||
Key? key,
|
||||
BuildContext? context,
|
||||
FormFieldSetter<bool>? onSaved,
|
||||
bool initialValue = false,
|
||||
bool autovalidate = false,
|
||||
bool enabled = true,
|
||||
IconData trueIcon = Icons.check,
|
||||
IconData falseIcon = Icons.check_box_outline_blank,
|
||||
Color trueIconColor,
|
||||
Color falseIconColor,
|
||||
Color disabledColor,
|
||||
Color? trueIconColor,
|
||||
Color? falseIconColor,
|
||||
Color? disabledColor,
|
||||
double padding = 24.0,
|
||||
double iconSize,
|
||||
double? iconSize,
|
||||
}) : super(
|
||||
key: key,
|
||||
onSaved: onSaved,
|
||||
|
@ -28,7 +28,7 @@ class CheckboxIconFormField extends FormField<bool> {
|
|||
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(padding),
|
||||
child: state.value
|
||||
child: state.value!
|
||||
? _createTappableIcon(state, enabled, trueIcon,
|
||||
trueIconColor, disabledColor, iconSize)
|
||||
: _createTappableIcon(state, enabled, falseIcon,
|
||||
|
@ -37,11 +37,11 @@ class CheckboxIconFormField extends FormField<bool> {
|
|||
);
|
||||
|
||||
static Widget _createTappableIcon(FormFieldState<bool> state, bool enabled,
|
||||
IconData icon, Color iconColor, Color disabledColor, double iconSize) {
|
||||
IconData icon, Color? iconColor, Color? disabledColor, double? iconSize) {
|
||||
return IconButton(
|
||||
onPressed: enabled
|
||||
? () {
|
||||
state.didChange(!state.value);
|
||||
state.didChange(!state.value!);
|
||||
}
|
||||
: null,
|
||||
icon: Icon(icon,
|
||||
|
|
|
@ -3,20 +3,20 @@ import 'package:flutter/material.dart';
|
|||
/// Use CheckboxListTile as part of Form
|
||||
class CheckboxListTileFormField extends FormField<bool> {
|
||||
CheckboxListTileFormField({
|
||||
Key key,
|
||||
Widget title,
|
||||
BuildContext context,
|
||||
FormFieldSetter<bool> onSaved,
|
||||
FormFieldValidator<bool> validator,
|
||||
Key? key,
|
||||
Widget? title,
|
||||
BuildContext? context,
|
||||
FormFieldSetter<bool>? onSaved,
|
||||
FormFieldValidator<bool>? validator,
|
||||
bool initialValue = false,
|
||||
bool autovalidate = false,
|
||||
bool enabled = true,
|
||||
bool dense = false,
|
||||
Color errorColor,
|
||||
Color activeColor,
|
||||
Color checkColor,
|
||||
Color? errorColor,
|
||||
Color? activeColor,
|
||||
Color? checkColor,
|
||||
ListTileControlAffinity controlAffinity = ListTileControlAffinity.leading,
|
||||
Widget secondary,
|
||||
Widget? secondary,
|
||||
}) : super(
|
||||
key: key,
|
||||
onSaved: onSaved,
|
||||
|
@ -36,7 +36,7 @@ class CheckboxListTileFormField extends FormField<bool> {
|
|||
onChanged: enabled ? state.didChange : null,
|
||||
subtitle: state.hasError
|
||||
? Text(
|
||||
state.errorText,
|
||||
state.errorText!,
|
||||
style: TextStyle(color: errorColor),
|
||||
)
|
||||
: null,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue