FLUTTER ECOSYSTEM

fluttercommunity/dart_sealed_unions

Dart 用のシールドユニオン。メンテナー:@nodinosaur

dart_sealed_unions のプロジェクト画像
Stars
66
Forks
7
最終プッシュ(UTC)
2021/03/18
プロジェクト状態
公開中
Flutter Community GitHub avatar
GITHUB Organization

Flutter Community ↗

A central place for all community made Flutter packages. To get started, see the README of the 'community' repository.

言語Dart

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 1 件
  • test開発用^1.16.8

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

README を開く / 閉じる

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

The Apache Software License, Version 2.0

See LICENSE.md

Flutter Community: sealed_unions