Buscar pacotes, repositórios e categorias de apps

Repositório GitHubfelangel/sealed_flutter_bloc

sealed_flutter_bloc

Extensão de gerenciamento de estado flutter_bloc que integra sealed_unions.

Capa do projeto sealed_flutter_bloc
Estrelas
78
Forks
12
Último push (UTC)
24 de mar. de 2024
Status do projeto
Arquivado

README original

Texto original em inglês. Visite o GitHub para a versão atual.

⚠️ This package has been discontinued in favor of the built-in sealed class modifier introduced in Dart 3.0. ⚠️

Sealed Flutter Bloc

build codecov Star on Github style: effective dart Flutter Website Awesome Flutter Flutter Samples License: MIT Discord Bloc Library

flutter_bloc meets sealed_unions


Sponsors

Our top sponsors are shown below! [Become a Sponsor]


Try the Flutter Chat Tutorial  💬

Quick Start

Extend UnionNImpl
class MyState extends Union4Impl<Initial, Loading, Success, Failure> {
  static final unions = const Quartet<Initial, Loading, Success, Failure>();

  MyState._(Union4<Initial, Loading, Success, Failure> union) : super(union);

  factory MyState.initial() => MyState._(unions.first(Initial()));

  factory MyState.loading() => MyState._(unions.second(Loading()));

  factory MyState.success({required String data}) =>
      MyState._(unions.third(Success(data: data)));

  factory MyState.failure({required String error}) =>
      MyState._(unions.fourth(Failure(error: error)));
}

class Initial {}

class Loading {}

class Success {
  final String data;

  Success({required this.data});
}

class Failure {
  String error;

  Failure({required this.error});
}
Use SealedBlocBuilder
class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SealedBlocBuilder4<MyBloc, MyState, Initial, Loading, Success,
        Failure>(
      builder: (context, states) => states(
        (initial) => Text('Initial'),
        (loading) => CircularProgressIndicator(),
        (success) => Text('Success: ${success.data}'),
        (failure) => Text('Failure: ${failure.error}'),
      ),
    );
  }
}

Additional Examples

More examples can be found at sealed_flutter_bloc_samples.

Felix Angelov GitHub avatar
Autor no GitHub

Felix Angelov ↗

software engineer by day, software engineer by night.

LinguagensDartCMakeC++HTMLSwiftCKotlinObjective-C

Categorias

Dependências usadas

Lista de dependências 5 itens

Como escolher um repositório para seu projeto?

Filtre pelo caso de uso, compare a atividade e confira o projeto original antes de adotá-lo.

  1. Busque por nome, autor ou descrição e filtre por tema.
  2. Compare estrelas, forks e envios recentes. Estrelas indicam interesse, mas não garantem qualidade.
  3. Confira o README, a licença e as issues no GitHub antes de usar o projeto.

Fontes e manutenção

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗