Skip to main content

prefer-bloc-event-suffix

added in: 1.25.0
⚙️
Free+

Warns when a Bloc event class name does not match the configured pattern.

⚙️ Config

Set name-pattern (default is Event$) to set a regular expression pattern for bloc event names.

Set ignore-subclasses (default is true) to skip the name check for event subclasses.

analysis_options.yaml
dart_code_metrics:
rules:
- prefer-bloc-event-suffix:
name-pattern: Event$
ignore-subclasses: true

Example

❌ Bad:

class SomeClass {}

// LINT: The name of this bloc event class is expected to match the configured pattern: 'Event$'.
class CounterBloc extends Bloc<SomeClass, int> {
...
}

✅ Good:

class SomeEvent {}

class CounterBloc extends Bloc<SomeEvent, int> {
...
}