function_types 0.1.0 copy "function_types: ^0.1.0" to clipboard
function_types: ^0.1.0 copied to clipboard

Defines the function types with different arities via `typedefs`.

example/example.dart

import 'package:function_types/function_types.dart';

void main() {
  int add(int a, int b) => a + b;

  var op1 = new Add<int>(add);
  print(op1.add(3, 2));

  var op2 = new Sub<int>((int a, int b) => a - b);
  print(op2.sub(3, 2));

  Func2<int, int, int> mul = (int a, int b) => a * b;
  print(mul(3, 2));

  toString = (Object o) => "String($o)";
  print(toString(123));
}

late Func1<Object, String> toString;

class Add<T> {
  final Func2<T, T, T> add;

  Add(this.add);
}

class Sub<T> {
  final Func2<T, T, T> sub;

  Sub(this.sub);
}
1
likes
110
pub points
70%
popularity

Publisher

unverified uploader

Defines the function types with different arities via `typedefs`.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on function_types