Skip to main content


added in: 1.10.0

Warns if the configured import is not a named import.


This rule requires configuration in order to highlight any issues.

⚙️ Config

Set entries (default is empty) to configure a list of named import entries.

Each entry is either a map or a string.

If the entry is a map, the key represents the imported package name and the value is the expected name alias.

If the entry is a string, the value represents both the imported package name and the expected name alias.

- prefer-named-imports:
- test
- path: p
- "dart:io": io


With the configuration in the example above, here are some bad/good examples.

❌ Bad:

import 'package:test/test.dart'; // LINT
import 'package:some/other.dart';
import 'package:path/path.dart'; // LINT

✅ Good:

import 'package:test/test.dart' as test;
import 'package:some/other.dart';
import 'package:path/path.dart' as p;