bloc_gen_runner 0.0.1+2 copy "bloc_gen_runner: ^0.0.1+2" to clipboard
bloc_gen_runner: ^0.0.1+2 copied to clipboard

A powerful build_runner-based code generator for the BLoC state management pattern. Eliminates boilerplate by automatically generating abstract base classes that wire up event transformers, equality l [...]

example/lib/main.dart

import 'package:example/bloc/test_bloc.dart';
import 'package:example/bloc/test_event_and_state.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: .fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final testBloc = TestBloc();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: .center,
          children: [
            const Text('You have pushed the button this many times:'),
            Text(
              'Okey Baby',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async {
          testBloc.add(InitializeEvent(userId: 123));
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
1
likes
0
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

A powerful build_runner-based code generator for the BLoC state management pattern. Eliminates boilerplate by automatically generating abstract base classes that wire up event transformers, equality logic, and copyWith methods — letting you focus on business logic instead of ceremony. Supports Concurrent, Sequential, Restartable, Droppable, Debounce, and Throttle transformers via a type-safe annotation API, with zero changes required to your existing BLoC code.

License

unknown (license)

Dependencies

analyzer, bloc_gen_annotations, build, build_config, built_collection, code_builder, dart_style, flutter, pub_semver, source_gen

More

Packages that depend on bloc_gen_runner