max-imports
Warns when the number of imports in a file exceeds the configured threshold.
⚙️ Config
Set max-number
(default is 10
) to configure the maximum number of imports in a file.
analysis_options.yaml
dart_code_metrics:
rules:
- max-imports:
max-number: 10
Example
❌ Bad:
// LINT: The number of imports in this file exceeds the configured threshold.
// Try reducing the number of imports.
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:another/another.dart';
✅ Good:
import 'package:flutter/material.dart';