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

A customizable code generator for repository patterns. Generates boilerplate-free repository implementations with configurable templates, presets, and build.yaml support.

example/example.dart

// ignore_for_file: unused_import, unused_element
import 'package:simple_repository_generator/generate.dart';

/// Example repository using @Generate annotation.
///
/// The generator will create a mixin `UserRepositoryGenerated` that implements
/// all annotated methods, wrapping API calls with the configured handler.
///
/// ```dart
/// // user_repository.dart
/// import 'package:simple_repository_generator/generate.dart';
/// import 'package:simple_network_handler/simple_network_handler.dart';
///
/// part 'user_repository.gen.dart';
///
/// abstract class UserRepository {
///   @Generate(apiClient: UserApi)
///   Future<Either<Failure, User>> getUser(String id);
///
///   @Generate(apiClient: UserApi, refreshes: [User])
///   Future<Either<Failure, User>> updateUser(User user);
/// }
/// ```
///
/// Implementation:
/// ```dart
/// // user_repository_impl.dart
/// @Singleton(as: UserRepository)
/// class UserRepositoryImpl extends UserRepository with UserRepositoryGenerated {
///   @override
///   final UserApi apiClient;
///
///   UserRepositoryImpl(this.apiClient);
/// }
/// ```
///
/// Configure via build.yaml:
/// ```yaml
/// targets:
///   $default:
///     builders:
///       simple_repository_generator|simple_repository_generator:
///         options:
///           preset: "simple_network_handler"
///           # Or customize:
///           # vars:
///           #   wrapper: "CustomHandler.call"
///           #   refresh: "CustomRefreshBus.emit"
/// ```
void main() {
  // See README.md for full documentation
}
1
likes
130
points
85
downloads

Documentation

API reference

Publisher

verified publisherkeep-it-simple.dev

Weekly Downloads

A customizable code generator for repository patterns. Generates boilerplate-free repository implementations with configurable templates, presets, and build.yaml support.

Repository (GitHub)
View/report issues

Topics

#code-generation #repository-pattern #build-runner #source-gen

License

MIT (license)

Dependencies

analyzer, build, mustache_template, source_gen

More

Packages that depend on simple_repository_generator