Skip to main content

avoid-unnecessary-digit-separators

dart 3.6+
configurable
pro+

Suggests removing digit separators in short numbers to improve readability.

⚙️ Config

Set max-length (default is 5) to configure the maximum number of digits.

analysis_options.yaml
dart_code_metrics:
rules:
- avoid-unnecessary-digit-separators:
max-length: 5

Example

❌ Bad:

void fn() {
// LINT: Avoid adding digit separators to short numbers. Try removing them.
final value = 1_00;

// LINT: Avoid adding digit separators to short numbers. Try removing them.
final another = 1_0.23;
}

✅ Good:

void fn() {
final value = 100;
final dbl = 10.23;
}

Additional Resources