sealed_unions 2.0.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 84

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: "^2.0.0"

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) flutterconsortium 2018

The Apache Software License, Version 2.0

See LICENSE.md

2.0.0

  • Removed functions package in favour of func

1.0.0

  • Initial Release

Use this package as a library

1. Depend on it

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


dependencies:
  sealed_unions: "^2.0.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:sealed_unions/sealed_unions.dart';
  
Version Uploaded Documentation Archive
2.0.0 Jan 10, 2018 Go to the documentation of sealed_unions 2.0.0 Download sealed_unions 2.0.0 archive
1.0.0 Jan 5, 2018 Go to the documentation of sealed_unions 1.0.0 Download sealed_unions 1.0.0 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
68 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
99 / 100
Overall score:
Weighted score of the above. [more]
84
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:sealed_unions/sealed_unions.dart.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 32 hints.

    Run dartfmt to format lib/factories/doublet_factory.dart.

    Run dartfmt to format lib/factories/nullet_factory.dart.

    Similar analysis of the following files failed:

    • lib/factories/octet_factory.dart (hint)
    • lib/factories/quartet_factory.dart (hint)
    • lib/factories/quintet_factory.dart (hint)
    • lib/factories/septet_factory.dart (hint)
    • lib/factories/sextet_factory.dart (hint)
    • lib/factories/singlet_factory.dart (hint)
    • lib/factories/triplet_factory.dart (hint)
    • lib/generic/union_0_first.dart (hint)
    • lib/generic/union_8_third.dart (hint)
    • lib/generic/union_9_eighth.dart (hint)
    • lib/generic/union_9_fifth.dart (hint)
    • lib/generic/union_9_first.dart (hint)
    • lib/generic/union_9_fourth.dart (hint)
    • lib/generic/union_9_ninth.dart (hint)
    • lib/generic/union_9_second.dart (hint)
    • lib/generic/union_9_seventh.dart (hint)
    • lib/generic/union_9_sixth.dart (hint)
    • lib/generic/union_9_third.dart (hint)
    • lib/implementations/union_0_impl.dart (hint)
    • lib/implementations/union_1_impl.dart (hint)
    • lib/implementations/union_2_impl.dart (hint)
    • lib/implementations/union_3_impl.dart (hint)
    • lib/implementations/union_4_impl.dart (hint)
    • lib/implementations/union_5_impl.dart (hint)
    • lib/implementations/union_6_impl.dart (hint)
    • lib/implementations/union_7_impl.dart (hint)
    • lib/implementations/union_8_impl.dart (hint)
    • lib/implementations/union_9_impl.dart (hint)
    • lib/sealed_unions.dart (hint)
    • lib/union_0.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use sealed_unions.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
func ^1.0.0 1.0.0
Dev dependencies
test ^0.12.4+5