this is my info_card
class InfoCard extends StatelessWidget {
final String title;
final String value;
final Color topColor;
final bool isActive;
final Function() onTap;
const InfoCard({
super.key,
required this.title,
required this.value,
required this.topColor,
required this.isActive,
required this.onTap,
});
@override
Widget build(BuildContext context) {
return Expanded(
child: InkWell(
onTap: onTap,
child: Container(
height: 120,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
offset: const Offset(0, 6),
color: Colors.grey.withOpacity(.1),
blurRadius: 12),
],
borderRadius: BorderRadius.circular(8)),
child: Column(
children: [
Row(
children: [
Expanded(
child: Container(
color: topColor,
height: 5,
),
)
],
),
Expanded(child: Container()),
RichText(
textAlign: TextAlign.center,
text: TextSpan(children: [
TextSpan(
text: "$titlen",
style: TextStyle(
fontSize: 16,
color: isActive
? colorScheme.primary
: colorScheme.onBackground)),
TextSpan(
text: value,
style: TextStyle(
fontSize: 40,
color: isActive
? colorScheme.primary
: colorScheme.onBackground)),
])),
Expanded(child: Container())
],
),
),
),
);
}
}
and this is the card on my dashboard
InfoCard(
title: "Scylla Serrata",
value: "56",
topColor: Colors.brown,
isActive: false,
onTap: () {}),
I want to change the isActive to true so that the card text color will be updated. Hence, highlighting it for better user experience. However, i don’t know how to change the isActive which is currently ‘false’ to true so that the color will change when clicked. Any help please.
New contributor
Keannu Gran is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.