Closed jtaxiexpress closed 2 years ago
@jtaxiexpress Hi! Could you share your code?
I can't see the validator in my app. The status of my checkbox changes, so I can check myself in.
Container(child: (() {
if (userAge < 20) {
return Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Form(
key: UniqueKey(),
child: CheckboxListTileFormField(
onSaved: (bool? value) {
isCheckBoxChange.state = value!;
},
onChanged: (value) {
if (value) {
print(value);
} else {
print(value);
}
},
validator: (value) {
if (value!) {
return null;
} else {
return 'False';
}
},
activeColor: Colors.white,
checkColor: Colors.grey,
title: Text(
"agree",
style: TextStyle(color: Colors.white),
),
),
),
);
} else {
return Text("");
}
})())
The default autovalidateMode
is AutovalidateMode.disabled
. So no validation is done without calling formGlobalKey.currentState.validate()
. You have to change the autovalidateMode
if you want different behavior
@jtaxiexpress https://github.com/reidha/checkbox_formfield/blob/master/example/lib/main.dart I added autovalidateMode to the sample just for a reference.
I tried to move the validator in every way I could.
However, it did not work with this package.