Linter Configuration
Tento obsah zatím není dostupný ve vašem jazyce.
By default, the bloc linter will not report any diagnostics unless you have explicitly configured a project’s analysis options.
To get started, create or modify the existing analysis_options.yaml
at the
root of your project to include a list of rules under the top-level bloc key:
bloc: rules: - avoid_flutter_imports
Run the linter using the following command in your terminal:
bloc lint .
The above command will analyze all files in the current directory and its subdirectories, but you can also lint specific files and directories by passing them as command-line arguments:
bloc lint src/ test/
The above command will analyze all code in the src
and test
directories.
If the avoid_flutter_imports
rule is enabled, any bloc or cubit file that
contains a flutter import will be reported as a warning:
import 'package:bloc/bloc.dart';import 'packages:flutter/material.dart';
class CounterCubit extends Cubit<int> { CounterCubit() : super(0);}
You can see the warning by running the bloc lint
command:
bloc lint counter_cubit.dart
The output should look like:
warning[avoid_flutter_imports]: Avoid importing Flutter within bloc instances. --> counter_cubit.dart:2 | | import 'package:flutter/material.dart'; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = hint: Blocs should be decoupled from Flutter. docs: https://bloclibrary.dev/lint-rules/avoid_flutter_imports
1 issue foundAnalyzed 1 file