Answers for "switch button flutter with icons"

1

flutter button with icon

ElevatedButton.icon(
          onPressed: () {},
          icon: Icon(Icons.email),
          label: Text("Contact me"),
          style: ElevatedButton.styleFrom(
            textStyle: TextStyle(fontSize: 15),
          ),
        ),
Posted by: Guest on September-18-2021
0

flutter change the icon of icon button on pressed

bool selected = true;

//...

Widget build(BuildContext context) {
	return Scaffold(
    	body: Center(
          child: IconButton(
              icon: Icon( selected ? Icons.celebration : Icons.title),
              onPressed: () {
                setState(() {
                  selected = !selected;
                });
              },
          ), //IconButton
   		), //Center
    ); //Scaffold
}
Posted by: Guest on March-24-2021

Browse Popular Code Answers by Language