cc_bloc

Creator: coderz1093

Last updated:

0 purchases

cc_bloc Image
cc_bloc Images

Languages

Categories

Add to Cart

Description:

cc bloc

CCBloc #
CCBloc is a package developed to simplify the usage of BLoC (Business Logic Component) in Flutter applications. This package helps you manage BLoC operations more efficiently and in a more organized manner. Below are the main features of the package and usage examples.
Features #

Simple and centralized BLoC management
Easy access to handle loading and update states
Dynamic management of modules and providers

Installation #
Add the following line to your pubspec.yaml file to include the package in your project:
dependencies:
cc_bloc: ^1.0.0
copied to clipboard
Then, run flutter pub get in the terminal to install the package.
Usage #
1. Managing BLoC with CCBloc #
The CCBloc class allows you to manage and access your BLoCs.
Registering a BLoC
To register a BLoC class:
CCBloc.register(MainCubit());
copied to clipboard
Accessing a BLoC
To access a registered BLoC:
var cubit = CCBloc.getModule<MainCubit>();
copied to clipboard
Handling BLoC States
To handle loading and update states:
CCBloc.loading<MainCubit>();
CCBloc.updated<MainCubit>();
copied to clipboard
2. BLoC Class #
Create a BLoC class and register it with CCBloc:
class MainCubit extends Cubit<MainState> {
MainCubit() : super(MainInitial()) {
CCBloc.register(this);
}

void fetch() async {
CCBloc.loading<MainCubit>();
// Perform BLoC operations
CCBloc.updated<MainCubit>();
}
}
copied to clipboard
3. Widget Usage #
Create a widget and apply the CCProvider mixin:
class MainPage extends CCStatelessWidget<MainCubit> {
MainPage({Key? key}) : super(key: key);

@override
void loading() {
print("Loading");
}

@override
void updated() {
print("Updated");
}

@override
Widget build(BuildContext context) {
return BlocBuilder<MainCubit, MainState>(
builder: (context, state) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
Text(
'2',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
);
},
);
}
}
copied to clipboard
Contributing #
If you'd like to contribute, please submit pull requests or report issues.
License #
This package is licensed under the MIT License. See the LICENSE file for details.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.