run_it 1.0.1 copy "run_it: ^1.0.1" to clipboard
run_it: ^1.0.1 copied to clipboard

A list of very useful extensions that allow you to execute code or a variable before assignment, or to check for null.

example/run_it_example.dart

import 'package:run_it/run_it.dart';

void main() {
  // [run] will have `null` or `void` as derfault return tupe.
  run(() => print('Hello World'));

  // [run] will have [int] as return type.
  int time = run(() => 10);

  // [runOn] will have [int] as return type and [it] will be [int]
  int houres = time.runOn((it) => it ~/ 3600);

  // [run] will have [double] as return type and [it] will be [int]
  double seconds = time.run((it) => it / 1000);

  // [let] will have `void` as derfault return tupe.
  seconds.let((it) => print("$it seconds AND $houres houres In $time"));

  print("-" * 36);
  /* ‼️‼️ Attention this execution can bug, some time. */
  dynamic map = {};
  map.run((it) => print(it)); // NoSuchMethodError: Class '_Map<dynamic, dynamic>' has no instance method 'run'.
  // Use on know types (advice).
}
1
likes
160
points
14
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A list of very useful extensions that allow you to execute code or a variable before assignment, or to check for null.

Repository (GitHub)
View/report issues

Topics

#extension #run #let #kotlin

License

BSD-3-Clause (license)

More

Packages that depend on run_it