leancode_contracts_generator 0.19.1 copy "leancode_contracts_generator: ^0.19.1" to clipboard
leancode_contracts_generator: ^0.19.1 copied to clipboard

Dart contracts client generator for a CQRS API.

leancode_contracts_generator

leancode_contracts_generator #

Installation #

dart pub add leancode_contracts_generator --dev

If your contracts use Topics additionally install leancode_pipe:

dart pub add leancode_pipe

Add dependencies for generating JSON serialization helpers:

dart pub add json_serializable --dev
dart pub add build_runner --dev

Usage #

Ensure that you have .NET SDK installed with version capable of building target contracts project.

The version of .NET generator is controlled using .NET tool manifest (see example), the presence of which is required for .NET generator to be found. If it's missing, one can be created with dotnet tool install dotnet-contracts-generate --create-manifest-if-needed.

First run will take longer due to the need to download external dependencies.

After running the contracts generator, generate the JSON serialization helpers:

dart run build_runner build

CLI #

First initialize a config file filled with defaults with dart run leancode_contracts_generator init, then generate client contracts code with dart run leancode_contracts_generator.

$ dart run leancode_contracts_generator --help
Command line utility for generating dart CQRS contracts

Usage: leancode_contracts_generator <command> [arguments]

Global options:
-h, --help    Print this usage information.

Available commands:
  init   Initialize a config file

Run "leancode_contracts_generator help <command>" for more information about a command.

Library #

import 'dart:io';

import 'package:leancode_contracts_generator/leancode_contracts_generator.dart';

Future<void> main(List<String> arguments) async {
  final generator = ContractsGenerator(
    ContractsGeneratorConfig(
      input: GeneratorScript.path(['ExampleContracts/**']),
      name: 'cool_name',
      output: Directory('lib'),
      extra: '// :)',
      include: RegExp(r'\w+(\.\w+)*'),
    ),
  );

  await generator.writeAll();
}

🛠️ Maintained by LeanCode #

This package is built with 💙 by LeanCode. We are top-tier experts focused on Flutter Enterprise solutions.

Why LeanCode? #

  • Creators of Patrol – the next-gen testing framework for Flutter.

  • Production-Ready – We use this package in apps with millions of users.

  • Full-Cycle Product Development – We take your product from scratch to long-term maintenance.


Need help with your Flutter project?

👉 Hire our team   •   Check our other packages