Need to make a status based on a boolean value to change an icon to tick if it is true and do nothing if its false. Tried to make logic but something not working well. Please help.
class OrderStatusBar extends StatefulWidget {
const OrderStatusBar( {Key? key, required this.title, required this.status}) : super(key: key);
final String title;
final bool status;
@override
State<OrderStatusBar> createState() => _OrderStatusBarState();
}
class _OrderStatusBarState extends State<OrderStatusBar> {
@override
Widget build(BuildContext context) {
return Row(
children: [
Text('${widget.title}'),
IconButton(
icon: true
? Icon(Icons.favorite_border)
: Icon(
Icons.favorite,
),
onPressed: () {
setState(() {
// Here we changing the icon.
var status = !true;
});
}),
],
);
}
}