0
(I’m new to language)
I have a checkbox to inform if the customer wants to receive (1) the push or not (0).
My idea is to create a Dynamic variable (to receive all types) and then convert true=1 and false=0 as in the example below, but I get the following error:
type 'int' is not a subtype of type 'bool'
Could someone help me or tell me what I’m doing wrong?
Example class
class _TesteState extends State<Teste> {
dynamic _ativado = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Teste"),
),
body: Center(
child: Row(
children: [
Text("Enviar para o histórico?"),
Checkbox(onChanged: (dynamic e) {
setState(() {
_ativado = e;
if(_ativado = true){
_ativado = 1;
}
else {
_ativado = 0;
}
});
},
value: _ativado,
),
],
),
),
);
} }
Note: I have tried to convert the _enabled variable to toInt before assigning 1 and 0 to it, but neither will it
Perfect, thanks!! As for the parénteses... Yes, I am a empres task and the API expects the values 0 and 1, so necessarily I have to return the same...
– Jonatan Rocha
I will study better possibilities to replace Dynamic, thanks for the guidelines
– Jonatan Rocha