fast_bloc_generators 0.0.2 copy "fast_bloc_generators: ^0.0.2" to clipboard
fast_bloc_generators: ^0.0.2 copied to clipboard

Bloc fast generator.

Motivation #

Bloc is awsome, but its have to many boilerplate code. So this package will help you pass the terious time by generate State, Event and Event the bloC for you.

Example
@fastBloc
abstract class GetTrivia{
  late Failure errorState;
  late List<Trivia> successState;

  GetListTriviaUseCase GetTriviaDataEvent(int value);
  DeleteTriviaUseCase DeleteTriviaDataEvent(int value);
}

Guide #

  • Step 1: create the abtract class and put the @fastBloc annotaion. You can get it from package(fast_bloc_annotations)

  • Step 2: declare 2 return types of the State. You need to change the Data Type but not the name.

  • Step 3: Create the function include:

      - GetListTriviaUseCase: name of the usecase(or any function)
      - GetTriviaDataEvent: name of the event 
      - int value: Event params
    
  • Step 4: To run the code generation, you need to add the build_runner in your pubspec.yaml and then run:

         dart run build_runner build
    

    -Step 5: enjoy the result

Injectable intergation #

if you use https://pub.dev/packages/injectable in for app: Try to add annotaion:

        @FastBloc(useInjectable: true)

Want more detail, visit my example project: #

https://github.com/ndkai/Bloc-Generator/tree/main/example

Happy coding <3

1
likes
90
points
173
downloads

Publisher

unverified uploader

Weekly Downloads

Bloc fast generator.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, fast_bloc_annotations, flutter, source_gen

More

Packages that depend on fast_bloc_generators