Yeah it was resolved! I just did some changes in demo_page.dart
to call the function from there.
This logic solved the bug.
// Calculate the incremental duration since the last save
int currentTimerValue = provider.timerValue.toInt();
int incrementalDuration = currentTimerValue - provider.lastSavedTime;
// Save the incremental duration if it's valid
if (incrementalDuration > 0) {
provider.addFocusSession(Duration(seconds: incrementalDuration),
isCompleted: true, taskType: selectedItem);
provider.lastSavedTime = currentTimerValue; // Update the last saved time
}