elapsed 1.0.7
elapsed: ^1.0.7 copied to clipboard
Get time elapsed for asynchronous function in a single line of code.

Get time elapsed for asynchronous function in a single line of code.
What does this do? #
- This package is written as a simplified form of
Stopwatchclass. And probably better. - Only contains one method which is
elapsed(...). - Only accepts a
Future<T>that the library will automatically await and record the time elapsed. - Where
<T>can be of any type including<void>. - The time elapsed will be returned alongside the actual result of the future.
Normal vs package:elapsed #
This is how you normally call an API with http package.
var response = await http.get(...);
print(response.body); // prints JSON data response.
But with this library, you can do this:
var data = await elapsed(http.get(...));
print(data.result.body); // prints JSON data response.
print(data.result.inMilliseconds); // prints time elapsed in milliseconds.
// Also has ".inSeconds" and ".inMinutes"
Comparison #
package:elapsed
Stopwatch class
manual implementation
Types #
Of course. Types are supported. Like this:
Disclaimer #
This is not an alternative to time_elapsed. This is a very different library.