Flutter Community: 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.3+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

Copyright (c) fluttercommunity 2019-2021

The Apache Software License, Version 2.0

See LICENSE.md

Flutter Community: sealed_unions

Libraries

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