Migrate to null-safety

fixes #1
This commit is contained in:
SimonIT 2021-08-17 13:48:08 +02:00
parent 97570ff2f9
commit 106f2d6bbb
No known key found for this signature in database
GPG key ID: 8D07E7C11D5705EE
7 changed files with 98 additions and 182 deletions

View file

@ -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,

View file

@ -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,