union 0.0.3+1
union: ^0.0.3+1 copied to clipboard

discontinued

Type safe union types for dart, by using extensions from Dart 2.6

example/example.dart

import 'package:union/union.dart';

void main() {
  Union2<int, double> union2 = 42.asFirst();

  Union3<int, double, String> upcast = union2; // works
  print(upcast.value); // 42

  print(upcast.map((a) => a * 2, (a) => '$a', (a) => a).value); // 84

  upcast = 'foo'.asThird();

  print(upcast.map((a) => a * 2, (a) => '$a', (a) => a).value); // 'foo'

  // Union2<int, double> downcast = upcast; // does not compile
}
19
likes
0
pub points
76%
popularity

Suggested replacement

freezed

Publisher

dash-overflow.net

Type safe union types for dart, by using extensions from Dart 2.6

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

More

Packages that depend on union