Skip to main content


added in: 1.6.0

Configure some imports that you want to ban.


This rule requires configuration in order to highlight any issues.

⚙️ Config

Set entries (default is empty) to configure a list of entries for imports to ban.

Each entry is an object with 4 fields: paths, deny, message and severity.

Set paths (can be a regular expression) to configure the list of paths the entry will apply to.

Set deny (can be a regular expression) to configure the list of imports to ban.

Set message to configure a user-facing message for each issue created from this config entry.

Set severity to override default severity for the given entry.

- avoid-banned-imports:
- paths: ['some/folder/.*\.dart', 'another/folder/.*\.dart']
deny: ['package:flutter/material.dart']
message: 'Do not import Flutter Material Design library, we should not depend on it!'
severity: error
- paths: ['core/.*\.dart']
deny: ['package:flutter_bloc/flutter_bloc.dart']
message: 'State management should be not used inside "core" folder.'

For Windows devices, ensure that the paths config works with Windows path separators.


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

❌ Bad:

import "package:flutter/material.dart"; // LINT
import "package:flutter_bloc/flutter_bloc.dart"; // LINT

✅ Good:

// No restricted imports in listed folders.