If I want to create elevated button in flutter, and make background something like green if condition true, or blue if false
can I use if condition with elevated button?
>Solution :
if you want to use ButtonStyle:
ElevatedButton(
onPressed: () {},
child: Text('button'),
style: ButtonStyle(
backgroundColor:MaterialStateProperty.all( yourCondetion ? Colors.green : Colors.blue,),
),
),
if you want to use ElevatedButton.styleFrom:
ElevatedButton(
onPressed: () {},
child: Text('button'),
style: ElevatedButton.styleFrom(
primary: yourCondetion ? Colors.green : Colors.blue,
),
),