type_extensions 0.0.1 copy "type_extensions: ^0.0.1" to clipboard
type_extensions: ^0.0.1 copied to clipboard

outdated

A small dart package which provides a cleaner interface for dealing with function types

A small dart package which provides a cleaner interface for dealing with function types.

The primary benefits of this package is when using higher order functions or callbacks.

The convention followed throughout is that the parameters are given as type parameters in order with the final parameter being the return type (if not an effect).

Usage #

Instead of annotating types such as:

  myFunction(Map<String, dynamic> Function(Object, int, String));

A cleaner interface can be used which makes the type of the function easier to decode at a glance:

  functionWithCallback(TernaryFn<Object, int, String, Map<String, dynamic>)

This reordering makes the flow of parameters easier to follow

API #

NullaryEffect #

A function type which accepts no parameters and returns nothing. This is synonymous with the builtin [VoidCallback]

NullaryFn #

A function type which accepts no parameters and returns a value [T]

UnaryEffect #

A function type which accepts one parameter [A] and return nothing

UnaryFn #

A function type which accepts on parameter [A] and returns a value [T]

BinaryEffect #

A function type which accepts two parameters [A] and [B] and returns nothing

BinaryFn #

A function type which accepts two parameters [A] and [B] and returns a value [T]

TernaryEffect #

A function type which accepts three parameters [A], [B], and [C] and returns nothing

TernaryFn #

A function type which accepts three parameters [A], [B], and [C] and returns a value [T]

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1
likes
25
pub points
0%
popularity

Publisher

unverified uploader

A small dart package which provides a cleaner interface for dealing with function types

Repository
View/report issues

License

MIT (LICENSE)

More

Packages that depend on type_extensions