Skip to content

Stopwatch

Daniel Wagner edited this page Aug 19, 2022 · 4 revisions

The stopwatch is part of the mainscreen. It is implemented in stopwatchbar.dart as a widget

Stopwatch Functionality

grafik

The stopwatch was implemented using this library. https://pub.dev/packages/stop_watch_timer The reset button, +1 sec and -1 sec button use a workaround to work. Basically the time gets reset, the preset time gets cleared and a new preset time gets set. There is no simple function to simply adjust the time of the timer manually hence the workaround.

The function of the plus and minus button changing the time was outsourced into the changeTime method which then updates the presetTime (time the timer starts with) and thus by reseting the timer the current time. The changeTime method uses a delta to update the time. For the plus and minus button this delta is one second.

Popup when clicking on Stopwatch (Issue #319)

Bildschirmfoto_von_2022-07-15_10-30-23
The Container which displays the time using a StreamBuilder was changed to a TextButton. On pressing it, the function callStopWatch() is called. A dialog opens which is similar to the dialog opening when clicking on the score. The difference is, that here the Stopwatch of the current game is accessed through the PersistentController and the functions of the StopwatchTimer widget are used (see Flutter Doku).

  • The functions setMinutes and setSeconds are used to set a new time from the stopwatch popup.They use a similar mechanism as changeTime but this time applied to minutes and seconds

Clone this wiki locally