Import prefix is not lowercase_with_underscores

ID

dart.maintainability.library_prefixes_comply_naming_conventions

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Naming

Language

Dart

Description

Reports an import prefix declared with as that contains an uppercase letter, such as as Foo_Bar, as httpClient or as JSON, instead of the lowercase_with_underscores form the Dart style guide prescribes for library prefixes.

Rationale

A prefix is written at every use site, so its spelling is read far more often than it is declared. Dart reserves UpperCamelCase for types and lowerCamelCase for members, which makes an uppercase-bearing prefix read as a class or a variable - JSON.decode(…​) looks like a static call on a type, and httpClient.get(…​) like a call on an object. Keeping prefixes in lowercase_with_underscores makes the difference between a namespace and a value visible at a glance and keeps them consistent with package names.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Import prefix is not lowercase_with_underscores
import 'package:foo_bar/foo_bar.dart' as Foo_Bar;

Remediation

Rename the prefix to lowercase_with_underscores - as foo_bar, as http_client, as convert - and update the use sites. Prefer the package’s own short name where one is idiomatic (as math, as p).

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved