vendredi 24 juin 2022

Check box not working when called as a function

I am working on a flutter-dart application. I have to make a check box. I tried making the text box in Row under scaffold and it worked. Now I made a checkBox function and tried calling it instead of having entire code twice(since I had to repeat the similar task) and I am not able to check the text box. I am not getting where I am going wrong

Defined boolean

bool agreeTerms = false;

Function

CheckBox(String conditionText, bool agree) {
return Row(
  children: [
    Material(
      child: Transform.scale(
        scale: 1.25,
        child: Checkbox(
          shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(5)),
          value: agreeTerms,
          onChanged: ((value) {
            setState(() {
              agree = value ?? false;
            });
          }),
        ),
      ),
    ),
    Text(
      conditionText,
      style: TextStyle(fontSize: 10),
      overflow: TextOverflow.ellipsis,
    ),
  ],
);

Calling the Function, inside the scaffold.

Row(
                  children: [
                    (CheckBox(
                        'Terms and condition here',
                        agreeTerms)),
                  ],
                )



Aucun commentaire:

Enregistrer un commentaire