0 purchases
dart enum to string check
ATTENTION #
Because last Dart version supports name parameter this plugin is recommended to use on old Dart revisions. Right now repository is not in Archive because plugin have some bugs that can be fixed in future. After all checks and fully compatible understanding repository can be placed to Archive. #
dart_enum_to_string_check #
About #
Plugin for Dart Analyzer to checking enum.toString() usages.
Motivation #
Default Enum.toString() method represents an enum constant as class name + constant name (example: Colors.green but not green). In some cases this cast is not valid for a program logic (parse values to DB or JSON and vice versa) and can causing some problems (when from DB you get a strings without class names, "green" == Colors.green.toString() is not as we needed). Plugin helps to prevent described problem.
How to use #
From Dart Analyzer Server #
Add plugin as development dependency in pubspec.yml:
dev_dependencies:
dart_enum_to_string_check: ^0.8.3
copied to clipboard
Add plugin name to analysis_options.yaml:
analyzer:
plugins:
- dart_enum_to_string_check
copied to clipboard
Then restart Dart Analyzer Server.
From CLI #
With pub
To get dart_enum_to_string_check from pub, run from the shell:
Dart
pub global activate dart_enum_to_string_check
copied to clipboard
Flutter
flutter pub global activate dart_enum_to_string_check
copied to clipboard
Then run from project folder:
Dart
dart_enum_to_string_check
copied to clipboard
Flutter
flutter pub global run dart_enum_to_string_check
copied to clipboard
Without pub
Download plugin to your machine and provide bin/ location to PATH. Then run from project folder:
dart dart_enum_to_string_check.dart
copied to clipboard
References #
Solutions from dart-code-metrics by Wrike:
Files resolving in Dart Analyzer Plugin
Dart Analyzer Plugin utils
How to contribute #
Read Commit Convention. Make sure your build is green before you contribute your pull request. Then:
$ dart analyze
$ dart test
copied to clipboard
If you don't see any error messages, submit your pull request.
Contributors #
@fartem as Artem Fomchenkov
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.