final tomorrowMidnight = DateTime( now.year, now.month, now.day + 1, 0, 0); // Midnight of the next day
final initialDelay = tomorrowMidnight.isBefore(now) ? tomorrowMidnight.add(const Duration(days: 1)).difference( now) // If it's already past midnight, schedule for the next day
: tomorrowMidnight.difference(now);
Workmanager().initialize(callbackDispatcher);
Workmanager().registerPeriodicTask( "newtask",
"CheckTask",
initialDelay: initialDelay,
frequency: const Duration(days: 1) // Run daily );
final tomorrowMidnight = DateTime( now.year, now.month, now.day + 1, 0, 0); // Midnight of the next day final initialDelay = tomorrowMidnight.isBefore(now) ? tomorrowMidnight.add(const Duration(days: 1)).difference( now) // If it's already past midnight, schedule for the next day : tomorrowMidnight.difference(now); Workmanager().initialize(callbackDispatcher); Workmanager().registerPeriodicTask( "newtask", "CheckTask", initialDelay: initialDelay, frequency: const Duration(days: 1) // Run daily );
that's not working****