Skip to main content

stealth_enum_generator 1.0.5 copy "stealth_enum_generator: ^1.0.5" to clipboard
stealth_enum_generator: ^1.0.5 copied to clipboard

Code generator for stealth_enum that transforms private enums into zero-cost obfuscated extension types to eliminate AOT binary metadata.

pub version License: MIT Dart Flutter
codecov

Support me on Ko-fi

The companion build_runner code generator for stealth_enum.

This package transforms @StealthEnum() annotated private Dart enums into zero-cost, obfuscated Dart 3 extension types to neutralize AI-driven reverse engineering pipelines (REA, Blutter, Ghidra).

Getting started #

Add stealth_enum_generator to your dev_dependencies alongside build_runner, and stealth_enum to your dependencies:

dependencies:
  stealth_enum: ^1.0.0

dev_dependencies:
  build_runner: ^2.4.0
  stealth_enum_generator: ^1.0.0

Then run:

dart pub get
# or for Flutter:
flutter pub get

How it works #

StealthEnumGenerator extends GeneratorForAnnotation<StealthEnum> from source_gen:

  1. Validation: Inspects @StealthEnum() annotations and ensures they are applied to private EnumElement declarations.
  2. Identifier Extraction: Resolves the public type name (strips the leading _ or applies the custom name: override).
  3. Entropy & Value Generation: Computes collision-free, deterministic 32-bit hex values for each constant using a seeded random distribution.
  4. Extension Type Synthesis: Emits an extension type const <Name>._(int rawValue) with static constants, values list, safe tryFromRawValue() parsing, isValid validation, and inlined pattern matching.
  5. Fail-Closed Security: Emits explicit hex cases and fail-closed wildcards (_ => throw StateError('')) to guarantee that corrupted or unknown values never execute a privileged branch without leaking strings.
  6. Shared Pipeline Integration: Built with SharedPartBuilder so it seamlessly shares .g.dart files with json_serializable, freezed, and other generators.

For full documentation and examples, see the stealth_enum README.

Contributing #

PRs and issues are welcome! Please open an issue first for significant changes.

License #

Made with 💛 by aslamambiloly © 2026

12
likes
160
points
588
downloads

Documentation

API reference

Publisher

verified publisheraslamambiloly.2bd.net

Weekly Downloads

Code generator for stealth_enum that transforms private enums into zero-cost obfuscated extension types to eliminate AOT binary metadata.

Repository (GitHub)
View/report issues

Topics

#security #obfuscation #reverse-engineering #code-generation #build-runner

License

MIT (license)

Dependencies

analyzer, build, source_gen, stealth_enum

More

Packages that depend on stealth_enum_generator