Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

xamantra/elapsed

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get time elapsed for asynchronous function in a single line of code.

Pub Version Testing Status


What does this do?

  • This package is written as a simplified form of Stopwatch class. 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.inMilliseconds); // prints time elapsed in milliseconds.
// Also has ".inSeconds" and ".inMinutes"

Comparison

package:elapsed

package:elapsed


Stopwatch class

manual implementation


manual implementation

manual implementation


Types

Of course. Types are supported. Like this:

typed


Null-safety

dependencies:
  # ...
  elapsed: ^1.2.0 # use this version for null-safety. Requires dart 2.12.0 or Flutter 2.0.0 for flutter.
  # OR
  elapsed: 1.0.7 # no null-safety. can be used in older version of dart and flutter.
  # ...

Disclaimer

This is not an alternative to time_elapsed. This is a very different library.


About

Get time elapsed for asynchronous function in a single line of code.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.