Prefer File Naming Conventions
newdartrecommended
Prefer following file naming conventions.
Rationale
Section titled “Rationale”For consistency, ease of maintenance, and separation of concerns prefer to define bloc and cubit instances in their respective Dart files instead of inlining them.
Examples
Section titled “Examples”Prefer declaring bloc/cubit instances in their own respective files.
GOOD:
import 'package:bloc/bloc.dart';
class CounterCubit extends Cubit<int> { CounterCubit() : super(0);
void increment() => emit(state + 1);}BAD:
import 'package:bloc/bloc.dart';
class CounterCubit extends Cubit<int> { CounterCubit() : super(0);
int increment() { emit(state + 1); return state; }}Enable
Section titled “Enable”To enable the prefer_file_naming_conventions rule, add it to your
analysis_options.yaml under bloc > rules:
bloc: rules: - prefer_file_naming_conventionsbloc: rules: prefer_file_naming_conventions: true