no_bloc 0.1.2 copy "no_bloc: ^0.1.2" to clipboard
no_bloc: ^0.1.2 copied to clipboard

discontinuedreplaced by: ezbloc_flutter
outdated

Making blocs easy again. A simplified library for the original bloc approach.

A Dart library to make blocs easy again.

Checkout the flutter version too:

Why? #

Existing bloc packages require too much "State and Event" boilerplate, and expose underlying Streams complexity.

Pros 👍 #

  • Easy to use and works out of the box
  • Complete abstraction over Streams and Subscriptions
  • No more states or events boilerplate bloat (just work with functions)

Example #

Easy Bloc hides all streams/yields, exposing only simple functions setState(), setBusy() and setError():

import 'package:no_bloc/no_bloc.dart';

class CounterBloc extends Bloc {
  void increment() => setState(value + 1);
  void decrement() => setState(value - 1);
}

void main() {
  final bloc = CounterBloc();
  
  bloc.increment();
}

A bit more complex bloc:
import 'package:no_bloc/no_bloc.dart';

class CounterBloc extends Bloc {
  void increment() async {
    if (value >= 10) {
      setError(StateError('Counter cannot go beyond 10'));
    }
    
    setBusy();
    await makeNetworkCall();
    
    setState(value + 1);
  }

  void decrement() => setState(value - 1);
}

void main() async {
  final bloc = CounterBloc();
  
  await bloc.increment();
}

Contribution ❤ #

Issues and pull requests are welcome

Please file feature requests and bugs at the issue tracker.

6
likes
0
pub points
5%
popularity

Publisher

verified publishermuha.dev

Making blocs easy again. A simplified library for the original bloc approach.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

built_value, equatable, hive, meta, path, pedantic, rxdart, synchronized, test

More

Packages that depend on no_bloc