conveniently library

Conveniently helps you write Dart code conveniently.

It provides various extension functions for very common operations.

Classes

Fail<V>
Failure case of Result.
Ok<V>
Success case of Result.
Result<V>
Result of a computation that may fail.

Extensions

ConvenientlyAny on V
ConvenientlyAsyncPredicate on Future<bool> Function(T)
ConvenientlyInt on int
ConvenientlyNullable on V?
ConvenientlyPredicate on bool Function(T)
Function1Extension on R Function(A)
Extension functions for functions of arity 1.
Function2Extension on R Function(A, B)
Extension functions for functions of arity 2.
Function3Extension on R Function(A, B, C)
Extension functions for functions of arity 3.
Records1 on (A)
Records2 on (A, B)
Records3 on (A, B, C)
Records4 on (A, B, C, D)
Records5 on (A, B, C, D, E)
Records6 on (A, B, C, D, E, F)
Records7 on (A, B, C, D, E, F, G)
Records8 on (A, B, C, D, E, F, G, H)

Functions

alwaysFalse(Object? anything) bool
Predicate function that always returns false.
alwaysTrue(Object? anything) bool
Predicate function that always returns true.
catching<V>(Future<V> action()) Future<Result<V>>
Run the given asynchronous action, capturing any Exception it may throw in a Result object.
catching$<V>(V action()) Result<V>
Run the given synchronous action, capturing any Exception it may throw in a Result object.
identity<T>(T t) → T
The identity function.
timing<V>(FutureOr<V> action()) Future<(Duration, V)>
Run the given asynchronous action, returning a Duration representing how long it took to complete, and the value returned by it.
timing$<V>(V action()) → (Duration, V)
Run the given synchronous action, returning a Duration representing how long it took to complete, and the value returned by it.

Exceptions / Errors

MappingFailureException<V>
Exception that gets wrapped into a Fail result in case a Result mapping operation throws.