carv_generators 1.0.0 copy "carv_generators: ^1.0.0" to clipboard
carv_generators: ^1.0.0 copied to clipboard

Code generation package for Carv App which works combinely with `carv_annotations` package.

Generators - Pub Package Annotations - Pub Package

Provides Dart Build System builders for Generating boilerplate code for Carv app.

The builders generate code when they find classes/functions annotated with classes defined in package:carv_annotations.

Supporting Builders #

- Model Validate function (will be generate as an Extension)

Setup #

To configure your project with carv_generators follow these steps;

Add dependencies in your pubspec.yaml file.

dependencies:
    carv_annotations: ^latest-version

dev_dependencies:
    build_runner:
    carv_generators: ^latest-version

create a build.yaml file in the root app folder and add the below code block.

targets:
  $default:
    builders:
      carv_generators|modelValidatableGenerator:
        enabled: true
        generate_for:
          - lib/**_model.dart

Given your Domain model is meeting_model.dart:

import 'package:carv_annotations/carv_annotations.dart';

part 'meeting_model.g.dart';

@ModelValidate([
    Validatable('name', Validator(ValidatorType.required)),
    Validatable('email', Validator(ValidatorType.email)),
    Validatable('password', Validator(ValidatorType.minLength, matcher: 8)),
])
class MeetingModel {
  @override
  final Meeting data; // your pb data model :-> Meeting(name, email, password)

    // the rest of the code
    // goes below
}

Then run the following command to generate code for you.

flutter pub run build_runner build

or

flutter pub run build_runner build --delete-conflicting-outputs 

TODO: #

- Improve test coverage
- Add more generators
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Code generation package for Carv App which works combinely with `carv_annotations` package.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

analyzer, build, carv_annotations, source_gen

More

Packages that depend on carv_generators