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),
      ),
    );
  }
}

Libraries

bloc_pod
A dependency injection as alternative to provider with Pod for Bloc.