flutter_custom_bloc 0.0.1 copy "flutter_custom_bloc: ^0.0.1" to clipboard
flutter_custom_bloc: ^0.0.1 copied to clipboard

The Flutter Custom BLoC Library offers a lightweight implementation of the BLoC pattern for efficient state management in Flutter applications. By utilizing Dart's streams, it separates business logic [...]

example/lib/main.dart

import 'package:example/counter_example/bloc/counter_bloc.dart';
import 'package:example/counter_example/ui/counter_screen.dart';
import 'package:flutter/material.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  CounterBloc counterBloc = CounterBloc();

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          CustomTextButton(
            text: "Counter Example",
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => const CounterScreen(),
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}

class CustomTextButton extends StatelessWidget {
  final String text;
  final VoidCallback onPressed;

  const CustomTextButton({
    super.key,
    required this.text,
    required this.onPressed,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onPressed,
      child: Container(
        padding: const EdgeInsets.all(8),
        margin: const EdgeInsets.all(12),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(8),
          color: Colors.deepPurple,
        ),
        child: Text(
          text,
          style: const TextStyle(
            color: Colors.white,
            fontSize: 16,
            fontWeight: FontWeight.bold,
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

The Flutter Custom BLoC Library offers a lightweight implementation of the BLoC pattern for efficient state management in Flutter applications. By utilizing Dart's streams, it separates business logic from the UI, featuring BlocProvider for dependency injection and BlocBuilder for reactive updates, enhancing code maintainability.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_custom_bloc