0
Good morning, I am developing an application and with the implementation of LGPD has become mandatory in the registration menus a checkbox with the famous "read and accept the terms of use and privacy policy". I am having difficulty performing the validation if the user clicked on the Checkbox. How could I make the field of checkbox mandatory? Similar to what the Validator of Textformfield ago.
In short, I would like the user to be obliged to click on the checkbox in order to be able to register. If anyone can help me, thank you!
import 'package:flutter/material.dart';
class checkbox extends StatefulWidget {
@override
_checkboxState createState() => _checkboxState();
}
class _checkboxState extends State<checkbox> {
bool _checked = false;
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
child: CheckboxListTile(
contentPadding: EdgeInsets.only(bottom: 3, left: 3, right: 3, top: 0),
title: Text("Ao se cadastrar você está concordando com os Termos de Uso e Política de Privacidade",
style: TextStyle(
fontSize: 13,
height: 1.2,
color: Colors.white
),
textAlign: TextAlign.justify,
),
controlAffinity: ListTileControlAffinity.leading,
activeColor: Colors.blue,
value: _checked,
onChanged: (bool valor) {
setState(() {
_checked = valor;
}
);
},
),
);
}
}
All the other validations worked perfectly, but I got in trouble here. Grateful!