Skip to content

FIX: prevent navigation block when device time is adjusted backward#994

Merged
jacobaraujo7 merged 3 commits intoFlutterando:masterfrom
joaovvrodrigues:remove-difftime-navigation
Jun 10, 2025
Merged

FIX: prevent navigation block when device time is adjusted backward#994
jacobaraujo7 merged 3 commits intoFlutterando:masterfrom
joaovvrodrigues:remove-difftime-navigation

Conversation

@joaovvrodrigues
Copy link

@joaovvrodrigues joaovvrodrigues commented Mar 31, 2025

Description

This PR fixes an issue where Modular’s navigation system could prevent page transitions if the device's date/time was adjusted backward.

Context

In some systems, the device’s date and time can be automatically synchronized via an NTP server, an API endpoint, or external hardware. If the device clock was ahead and then corrected to an earlier time, the time difference calculation (currentTime.difference(_lastClick)) would result in a negative value. Since the original code blocked navigation when this difference was less than 500ms, this could permanently prevent navigation.

Solution

Now, the time difference calculation ensures it never goes negative:

final diffTimes = currentTime.isBefore(_lastClick) ? 0 : currentTime.difference(_lastClick).inMilliseconds;

If currentTime is earlier than _lastClick, the difference is considered 0, allowing navigation to proceed as expected.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@jacobaraujo7 jacobaraujo7 merged commit cceffc1 into Flutterando:master Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants