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.


When trying to ban some methods in your package, it also triggers on imported from an external package code. But you can specify the name to ban (ex: '' instead of 'now').


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

⚙️ Config

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, 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.

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.

- banned-usage:
- type: List
- ident: sort
description: Use "sorted" instead
- 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
- ident: AnotherStrangeName
description: Oops
- ident: StrangeClass.someMethod
description: Please use a NonStrangeClass.someMethod instead
- ident:
description: Please use a instead
severity: error

This rule requires configuration in order to highlight any issues.


❌ 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();