Import prefix starts with an underscore

ID

dart.maintainability.library_prefixes_shouldn_start_underscore

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Naming

Language

Dart

Description

Reports an import prefix declared with as whose name starts with an underscore, such as import 'dart:math' as _math;.

Rationale

A leading underscore is Dart’s marker for library privacy, and it means something for declarations - a private class or field is invisible outside its library. An import prefix is already local to the file that declares it and cannot be exported, so the underscore buys no privacy at all; it only makes the prefix look like a private member of the enclosing library and puts a name in the file that readers expect to find declared there.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Import prefix starts with an underscore
import 'dart:math' as _math;

Remediation

Drop the leading underscore and rename the prefix to lowercase_with_underscores - as math, as intl, as heavy - and update its use sites.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved