ObjectExtensions<T> extension
Small helpers that work on any value.
Useful for chaining, especially with values that might be null.
final port = env['PORT']?.let(int.parse) ?? 8080;
final list = <int>[].also((it) => it.add(1));
final name = input.takeIf((s) => s.isNotEmpty) ?? 'anonymous';
- on
-
- T
Methods
-
also(
void action(T it)) → T -
Available on T, provided by the ObjectExtensions extension
Runsactionwith this value and gives back this value. -
let<
R> (R action(T it)) → R -
Available on T, provided by the ObjectExtensions extension
Runsactionwith this value and gives back its result. -
takeIf(
bool test(T it)) → T? -
Available on T, provided by the ObjectExtensions extension
This value if it passestest, otherwise null. -
takeUnless(
bool test(T it)) → T? -
Available on T, provided by the ObjectExtensions extension
This value if it failstest, otherwise null.