Skip to main content

smart_domain_generator 0.1.0 copy "smart_domain_generator: ^0.1.0" to clipboard
smart_domain_generator: ^0.1.0 copied to clipboard

Build runner generator for smart_domain repository use cases.

smart_domain_generator #

Generates UseCase classes from repository interfaces annotated with @GenerateUseCases().

Setup #

dependencies:
  smart_domain: ^0.3.0

dev_dependencies:
  build_runner: ^2.16.0
  smart_domain_generator: ^0.1.0

Add a part directive and annotate the repository:

import 'package:smart_domain/smart_domain.dart';

part 'orders_repository.g.dart';

@GenerateUseCases()
abstract interface class OrdersRepository {
  Future<Result<Order, Failure>> getOrder(int id);

  Future<Result<List<Order>, Failure>> getOrders();

  Future<Result<Order, Failure>> createOrder(CreateOrderParams params);
}

Generate the code:

dart run build_runner build

The generator creates GetOrderUseCase, GetOrderParams, GetOrdersUseCase, and CreateOrderUseCase. A parameter type ending in Params is reused. Other method parameters are wrapped in a generated params class.

0
likes
150
points
68
downloads

Documentation

API reference

Publisher

verified publisherpinz.dev

Weekly Downloads

Build runner generator for smart_domain repository use cases.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

analyzer, build, smart_domain, source_gen

More

Packages that depend on smart_domain_generator