Skip to main content

avoid-duplicate-named-imports

added in: 1.2.0
Free+

Warns when a file has duplicate imports that differ only in name prefix.

Duplicate named and regular imports can lead to unnecessary confusion when some declarations from the same import have a prefix and some do not. To avoid this, it's recommended to always have one import of a specific library.

Example

❌ Bad:

import 'dart:io' as io;
// LINT: Avoid declaring regular and named imports with the same URI. Try using only one of the duplicate imports.
import 'dart:io';

✅ Good:

import 'dart:io' as io; // Correct, only one import

Additional Resources