LetExtension<T extends Object> extension
Kotlin-style scope functions for non-nullable types.
These extensions bring Kotlin's popular scope functions to Dart, enabling concise transformations and side effects without intermediate variables.
Example
final formatted = getUserName()
.let((name) => name.toUpperCase())
.also((name) => print('Processing: $name'));
- on
-
- T
Methods
-
also(
void block(T it)) → T -
Available on T, provided by the LetExtension extension
Executesblockwiththisfor side effects, then returnsthis. -
let<
R> (R block(T it)) → R -
Available on T, provided by the LetExtension extension
Executesblockwiththisas the argument and returns the result. -
takeIf(
bool predicate(T it)) → T? -
Available on T, provided by the LetExtension extension
Returnsthisif it satisfiespredicate, otherwisenull. -
takeUnless(
bool predicate(T it)) → T? -
Available on T, provided by the LetExtension extension
Returnsthisif it does NOT satisfypredicate, otherwisenull.