magic_value_extractor 0.1.0 copy "magic_value_extractor: ^0.1.0" to clipboard
magic_value_extractor: ^0.1.0 copied to clipboard

Extracts hard-coded magic strings and numbers from Dart and Flutter sources into AppStrings / AppNumbers constants and rewrites the call sites for you.

Changelog #

0.1.0 #

First release.

  • dart run magic_value_extractor --target=lib/ --output=lib/constants/ finds magic strings and magic numbers and collects them into AppStrings / AppNumbers.
  • Call sites are rewritten into commented constant references (--comment-style=line|block|none).
  • Exclusions for URLs, hex colours, file paths, asset paths, empty strings, regular expressions, widget keys, logging calls, assert() and annotations — each individually switchable.
  • The common numbers (0, 1, -1, 0.0, 1.0, -1.0) and hex literals are ignored by default (--ignore-numbers).
  • Naming from a built-in Japanese→English dictionary with a romaji fallback, extra entries through --dictionary, and DeepL / LLM integration through --name-hook with an optional result cache (--name-cache).
  • Numbers are named after their value: double_16_0 / num_300 (--number-name-style=snake|camel).
  • Existing constant files are merged into, matching values rather than names, so constants renamed by hand are reused and manual edits survive.
  • Imports are inserted in dart:package: → relative order.
  • --dry-run, --verbose, --json-report, --min-occurrences, --japanese-only, --exclude, --verify=none|parse|analyze.
  • // magic:ignore and // magic:ignore-file for pinpoint exclusions.
  • Rewritten files are re-parsed before being written; a file that would break is left unchanged and reported.
  • Supports a wide analyzer range (>=7.4.0 <15.0.0) so that, as a dev_dependency, it never holds back the host project's toolchain: Dart 3.5 through the current SDK, alongside the latest build_runner / json_serializable.
0
likes
160
points
7
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Extracts hard-coded magic strings and numbers from Dart and Flutter sources into AppStrings / AppNumbers constants and rewrites the call sites for you.

Repository (GitHub)
View/report issues

Topics

#cli #refactoring #constants #codegen #i18n

License

MIT (license)

Dependencies

analyzer, args, path

More

Packages that depend on magic_value_extractor