Skip to main content


added in: 1.3.0

Configure some usages that you want to ban.

Example: When you add some extra functionalities to built-in Flutter functions (such as logging for showDialog), you may want to ban the original Flutter function and use your own version.


This rule requires configuration in order to highlight any issues.


This rule is an improved version of ban-name and they should not be used together.

⚙️ Config


This rule also triggers on code from external packages / core libraries. To avoid this, you can pass a more specific name (for example, '' instead of 'now').

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

Each entry is either an object with 3 fields (ident (or name-pattern), description and severity) or a type entry (type and entries).

Set type to configure the type for which the usages should be banned.

Set ident to configure the identifier name (to pass a regular expression, set name-pattern instead).

Set name-pattern (optional) to configure a regular expression for the identifier name.

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

Set severity to override default severity for the given entry.

Set paths (optional) to configure a list of regular expressions the entry will apply to.

- banned-usage:
- type: List
- ident: sort
description: Use "sorted" instead
- name-pattern: '^clear'
description: Do not use any clear method
- ident: reversed
description: Do not reverse a list
- ident: showDialog
description: Please use myShowDialog in this package
- ident: strangeName
description: The name is too strange
- .*.dart
- ident: AnotherStrangeName
description: Oops
- ident: StrangeClass.someMethod
description: Please use a NonStrangeClass.someMethod instead
- ident:
description: Please use a instead
severity: error
- ident: StaticClass.field
description: Do not use this field
- ident: MyEnum.firstValue
description: Do not use this enum value
- type: SomeClass
- ident: call
description: Do not use implicit call()


❌ Bad:

// suppose the configuration is the one shown above

showDialog('some_arguments', 'another_argument'); // LINT
material.showDialog('some_arguments', 'another_argument'); // LINT

var strangeName = 42; // LINT

void strangeName() {} // LINT

class AnotherStrangeName {
late var strangeName; // LINT

StrangeClass.someMethod(); // LINT
NonStrangeClass.someMethod();; // LINT; // LINT
class DateTimeTest {
final currentTimestamp =; // LINT
DateTime currentTimestamp = DateTime('01.01.1959');

final list = [1, 2, 3];
list.sort(); // LINT

✅ Good:


class DateTimeTest {
final currentTimestamp =;

final list = [1, 2, 3];
final newList = list.sorted();