bloc_pod 0.18.0 copy "bloc_pod: ^0.18.0" to clipboard
bloc_pod: ^0.18.0 copied to clipboard

A dependency injection for BLoC, implemented with Pod as alternative to provider.

Pod #

License: MIT

⚠️ Status: Experimental


A dependency injection and state management library, fast, simple and composable.

Inspired by Riverpod and Jōtai

Package Pub
pod pub package
flutter_pod pub package
bloc_pod pub package

Quick Start #

import 'package:flutter/material.dart';
import 'package:flutter_pod/flutter_pod.dart';

import 'package:bloc_pod/bloc_pod.dart';

/// Counter Events
sealed class CounterEvent {}
final class CounterIncrementPressed extends CounterEvent {}

/// Counter Bloc
class CounterBloc extends Bloc<CounterEvent, int> {
  CounterBloc() : super(0) {
    on<CounterIncrementPressed>((event, emit) => emit(state + 1));
  }
}

/// Create a Bloc Pod
final counterBloc = blocPod<CounterBloc, int>((_) => CounterBloc());

/// Usage of counter bloc in Widget
///
/// Requires add and import flutter_pod
class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final counter = context.watch(counterBloc);

    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: Text('$counter'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          context.read(counterBloc.notifier).add(CounterIncrementPressed());
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
3
likes
160
pub points
0%
popularity

Publisher

verified publishereronsoft.com

A dependency injection for BLoC, implemented with Pod as alternative to provider.

Homepage
Repository (GitHub)
View/report issues

Topics

#bloc #pod #atom #dependency-injection #state-management

Documentation

API reference

License

MIT (license)

Dependencies

bloc, pod

More

Packages that depend on bloc_pod