mercredi 16 juin 2021

I am having trouble with argument type 'void Function(bool)' can't be assigned to the parameter type 'void Function(bool?)?'

Below is my attempt to make a checkBox widget and used Bool, but when trying to run this function which I created with parameter bool. but this is the error I get

  • The argument type 'void Function(bool)' can't be assigned to the parameter type 'void Function(bool?)?'.

I tried looking for a solution dint find any. thanks in advance

import "package:flutter/material.dart" ;

void main() {
   runApp(new MaterialApp(
     home: new Baseapp(),
   ));
}

class Baseapp extends StatefulWidget{
  @override
  _State createState() => new _State();
}
class _State extends State<Baseapp> {
  bool _value1  = false;
  bool _value2 = false;
  void _value1Changed(bool value) =>   setState(() => _value1 = value);
  void _value2Changed(bool value) =>   setState(() => _value2 = value);


  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar:  new AppBar(
        title :  new  Text("NAME HERE", style :TextStyle(color:Colors.black)),
        backgroundColor: Colors.yellow ,
      ),
      body: new Container(
      padding :   new EdgeInsets.all(20),
        child: new Center(
          child: new Column(
            children:<Widget>[
             new  Checkbox(value: _value1, onChanged:_value1Changed),
             new CheckboxListTile(value: _value2, onChanged:_value2Changed )
            ],
          ),
        ),
      ),
    );
  }
}



Aucun commentaire:

Enregistrer un commentaire