Last active
June 19, 2020 15:58
-
-
Save aria-dev/04b6eac9e1c173a62398bce03b4fe649 to your computer and use it in GitHub Desktop.
Extended Stopwatch class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////Usage of the StopWatch class ////////////////////// | |
void main() { | |
var stopwatch = new StopWatch(); | |
stopwatch.start(); | |
stopwatch.milliseconds = 10000; //10 seconds have passed | |
print(stopwatch.elapsedDuration); | |
stopwatch.stop(); | |
} | |
////////////////////////////////////////////////////////////////////// | |
// StopWatch class // | |
///////////////////////////////////////////////////////////////////// | |
class StopWatch extends Stopwatch{ | |
int _starterMilliseconds = 0; | |
StopWatch(); | |
get elapsedDuration{ | |
return Duration( | |
microseconds: | |
this.elapsedMicroseconds + (this._starterMilliseconds * 1000) | |
); | |
} | |
get elapsedMillis{ | |
return this.elapsedMilliseconds + this._starterMilliseconds; | |
} | |
set milliseconds(int timeInMilliseconds){ | |
this._starterMilliseconds = timeInMilliseconds; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment