I have an app that I want to disable the button after 8 hours of use per day, being able to use it as many times as I want within 8 hours of the day.
Below is part of the button code:
children: [
if (onMenuButtonPressed != null)
Align(
alignment: Alignment.centerLeft,
child: CupertinoButton(
onPressed: onMenuButtonPressed,
//onPressed: (DateTime.now().second >= 1 && DateTime.now().second <= 12) ? null : () => onMenuButtonPressed,
minSize: 0,
padding: const EdgeInsets.all(8),
child: const Icon(
Ionicons.menu,
color: ColorPalette.neutral50,
),
),
),
I tried to include the code below, but it didn’t work and it was commented out:
onPressed: (DateTime.now().second >= 1 && DateTime.now().second <= 12) ? null : () => onMenuButtonPressed,
2
Answers
Try your code this way,
Try your code this way,