macro_kit 0.2.8 copy "macro_kit: ^0.2.8" to clipboard
macro_kit: ^0.2.8 copied to clipboard

A development-time macro system for Dart that generates code instantly for fast iteration without build_runner.

example/main.dart

import 'package:example/models.dart';
import 'package:macro_kit/macro_kit.dart';

void main() async {
  await runMacro(
    package: PackageInfo('example'),
    macros: {
      'DataClassMacro': DataClassMacro.initialize,
    },
    enabled: true,
  );

  final profile = UserProfile(name: 'Rebaz', age: 30);
  print(
    [
      profile.toJson(),
      profile.toString(),
      profile.copyWith(name: 'Rebe'),
    ].join('\n'),
  );

  print('-----');

  Animal animal = Cat(nickName: 'Niki', name: 'Lala');
  print(
    [
      animal.toJsonBy(),
      animal.copyWithBy(cat: (value) => value.copyWith(name: 'Nik')),
    ].join('\n'),
  );

  print('-----');

  Cat cat = CatData.fromJson(animal.toJsonBy());
  print(
    [
      cat.toJson(),
      cat.copyWith(name: 'Myaw'),
    ].join('\n'),
  );

  print('-----');

  final dog = Dog(big: true, name: 'Iby');
  final dog2 = AnimalData.fromJson(dog.toJson());
  print(dog2 == dog);
}
28
likes
0
points
1.84k
downloads

Publisher

verified publisherrebaz.xyz

Weekly Downloads

A development-time macro system for Dart that generates code instantly for fast iteration without build_runner.

Repository (GitHub)
View/report issues

Topics

#codegen #macro #builder #development #tooling

License

unknown (license)

Dependencies

analyzer, analyzer_plugin, change_case, collection, dart_style, hashlib, http, logging, meta, path, shelf, shelf_router, shelf_web_socket, source_helper, watcher, web_socket_channel, yaml

More

Packages that depend on macro_kit