liquid_codegen 0.1.2 copy "liquid_codegen: ^0.1.2" to clipboard
liquid_codegen: ^0.1.2 copied to clipboard

Optional YAML → typed LiquidEvent codegen for liquid_analytics. Generates sealed-class compatible event classes with no build_runner required.

example/main.dart

// Generate typed LiquidEvent classes from a YAML schema.
//
// Normally you would run the bundled CLI:
//
//   dart run liquid_codegen:generate --input events.yaml --output lib/events.dart
//
// This example calls the same library API directly.
import 'package:liquid_codegen/liquid_codegen.dart';

const String schemaYaml = '''
events:
  checkout_started:
    properties:
      cart_value: double
      item_count: int?      # trailing ? = optional
  promo_tapped:
    category: marketing     # routed to the marketing consent gate
    properties:
      campaign: String
  app_opened: {}            # no properties
''';

void main() {
  final schema = parseEventSchema(schemaYaml);

  print('Parsed ${schema.events.length} events:');
  for (final event in schema.events) {
    print('  ${event.name} -> class ${event.className} '
        '(${event.properties.length} properties, ${event.category})');
  }

  // The generated library is plain Dart — no build_runner, no annotations.
  print('\n--- generated ---\n');
  print(generateEventsLibrary(schema));
}
0
likes
160
points
153
downloads

Documentation

API reference

Publisher

verified publisherketok.id

Weekly Downloads

Optional YAML → typed LiquidEvent codegen for liquid_analytics. Generates sealed-class compatible event classes with no build_runner required.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#analytics #codegen #flutter

License

MIT (license)

Dependencies

args, path, yaml

More

Packages that depend on liquid_codegen