persisted_bloc_stream 4.2.6 copy "persisted_bloc_stream: ^4.2.6" to clipboard
persisted_bloc_stream: ^4.2.6 copied to clipboard

outdated

A new Flutter package project.

persisted_bloc_stream #

PersistedBlocStream is an extension of BlocStream, that adds persistence for offline caching etc.

Usage #

class CounterBlocActions {
  static Stream<int> increment(int i, _) async* {
    yield i + 1;
  }

  static Stream<int> decrement(int i, _) async* {
    yield i + 1;
  }
}

class CounterBloc extends PersistedBlocStream<int> {
  CounterBloc() : super(0);

  @override
  int fromJson(json) => json;

  @override
  dynamic toJson(int value) => value;
}

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  PersistedBlocStream.storage = await HiveStorage.build();
  runApp(MyApp());
}