common_bloc 0.1.1 copy "common_bloc: ^0.1.1" to clipboard
common_bloc: ^0.1.1 copied to clipboard

outdated

A collection of common blocs that maybe will be used very often (powered by the bloc library).

example/example.dart

import 'package:common_bloc/common_bloc.dart';

main(List<String> args) async {
  /// REST Bloc
  final RestBloc _restBloc = RestBloc('https://jsonplaceholder.typicode.com');

  ///Listen to changes
  _restBloc.listen((state) => state.when(
      uninitialized: () => print('Uninitialized'),
      error: (error) => print('Error: $error'),
      loading: () => print('Loading'),
      loaded: (data, lastPath, timestamp) => print('Loaded'),
      empty: () => print('Empty')));

  ///Get some values
  _restBloc.get('/posts');

  ///Close the stream
  _restBloc.close();

  /// Request Bloc
  final RequestBloc _requestBloc = RequestBloc();

  ///Listen to changes
  _requestBloc.listen((state) => state.when(
      uninitialized: () => print('Uninitialized'),
      error: (error) => print('Error: $error'),
      loading: () => print('Loading'),
      loaded: (data, lastAction, timestamp) => print('Loaded'),
      empty: () => print('Empty')));

  /// Perform a task
  _requestBloc.perform(
      () async => Future.delayed(Duration(seconds: 3), () => true),
      'TimerTask');

  ///Close the stream
  _requestBloc.close();
}
10
likes
0
pub points
4%
popularity

Publisher

verified publisherpixela.tech

A collection of common blocs that maybe will be used very often (powered by the bloc library).

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

bloc, flutter, freezed_annotation, http, http_interceptor, meta

More

Packages that depend on common_bloc