dart_sealed_unions

ACKNOWLEDGEMENTS

This library is a port of JavaSealedUnions originally created by Francisco (Paco) Estévez .

Dart port by George Medve with assistance from Jan Knotek and Brian Egan.

RATIONALE

Sealed classes are used for representing restricted class hierarchies, when a value can have one of the types from a limited set, but cannot have any other type. They are, in a sense, an extension of enum classes: the set of values for an enum type is also restricted, but each enum constant exists only as a single instance, whereas a subclass of a sealed class can have multiple instances which can contain state. Sealed classes are available in languages like Kotlin, or C#. Tagged unions are common on Swift and Rust.

We highly recommend reading the Rationale for the readme of JavaSealedUnions for an indepth explanation of the idea and application of the library.

MOTIVATION

This library was heavily inspired by RxEither and the wonderful Domain Driven Design (DDD) talk by Scott Wlaschin. This video by Scott Wlaschin will inspire you on how to apply DDD: Domain Driven Design, F# and Types

USAGE

The following example project: MVI Sealed Unions demonstrates the library application in a Flutter app.

INSTALLING

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  sealed_unions: "^3.0.1"

2.Install it

You can install packages from the command line:

with Flutter:

flutter packages get

with pub:

pub get

3. Import it

Now in your Dart code, you can use:

// for example import Union4
import 'package:sealed_unions/union_4.dart';

License

FCLogo

Copyright (c) fluttercommunity 2018

The Apache Software License, Version 2.0

See LICENSE.md

Libraries

doublet_factory
nonet_factory
nullet_factory
octet_factory
quartet_factory
quintet_factory
sealed_unions
septet_factory
sextet_factory
singlet_factory
triplet_factory
union_0
union_0_first
union_0_impl
union_1
union_1_first
union_1_impl
union_1_none
union_2
union_2_first
union_2_impl
union_2_second
union_3
union_3_first
union_3_impl
union_3_second
union_3_third
union_4
union_4_first
union_4_fourth
union_4_impl
union_4_second
union_4_third
union_5
union_5_fifth
union_5_first
union_5_fourth
union_5_impl
union_5_second
union_5_third
union_6
union_6_fifth
union_6_first
union_6_fourth
union_6_impl
union_6_second
union_6_sixth
union_6_third
union_7
union_7_fifth
union_7_first
union_7_fourth
union_7_impl
union_7_second
union_7_seventh
union_7_sixth
union_7_third
union_8
union_8_eighth
union_8_fifth
union_8_first
union_8_fourth
union_8_impl
union_8_second
union_8_seventh
union_8_sixth
union_8_third
union_9
union_9_eighth
union_9_fifth
union_9_first
union_9_fourth
union_9_impl
union_9_ninth
union_9_second
union_9_seventh
union_9_sixth
union_9_third