scope_function 1.0.3 copy "scope_function: ^1.0.3" to clipboard
scope_function: ^1.0.3 copied to clipboard

A Dart implementation similar to Kotlin scope functions, enable you for powerful chained programming style.

Scope Function #

A Dart implementation similar to Kotlin scope functions.

Used for chained programming style.

Getting started #

import 'package:scope_function/scope_function.dart';

Usage #

netWorkResponse.run(parseResponse)
    .let((it) => it.name)
    .also((name) => print("name: $name"))
    ?.takeif((it) => it.isNotEmpty);

Additional information #

  • Since Dart not support Context receiver as what Kotlin does, withThe, run implemented using it as argument.
  • Since with is keyword in dart, use name withThe instead.
  • Recommend use .. operator in replace of apply which is usually used as configure object.
  • Recommend define a function(named/unnamed), and use function.call in replace of run without receiver.
  • We usually choose function based on semantic distinction if both functions can be competent for the job.
3
likes
160
points
97
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart implementation similar to Kotlin scope functions, enable you for powerful chained programming style.

Repository (GitHub)
View/report issues

Topics

#kotlin #chained #scope #function #utility

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on scope_function