buildOption function
Implementation
Widget buildOption(
BuildContext context, {
required IconData icon,
Color iconColor = Colors.white,
required String text,
bool isVisible = true,
bool isEnabled = true,
Function? onTap,
BadgeData? setBadge,
}) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
if (isEnabled) {
onTap?.call();
}
},
child: Visibility(
visible: isVisible,
child: Opacity(
opacity: isEnabled ? 1.0 : 0.5,
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
child: Row(
children: [
if (setBadge == null)
Icon(icon, color: iconColor, size: 24)
else
Badge(
isLabelVisible: setBadge.unreadCount > 0,
label: Text(
setBadge.unreadCount.toString(),
style: const TextStyle(color: Colors.white),
),
offset: const Offset(4, 4),
backgroundColor: Colors.red,
child: Icon(icon, color: iconColor, size: 24),
),
const SizedBox(width: 10),
Text(
text,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
),
);
}