Dead Code in Flutter Is More Than an Analyzer Warning
Описание и применение
Инструмент flutter-dead-code-audit позволяет безопасно удалять действительно мертвый код в Flutter, отделяя механические доказательства от человеческого решения.
Задача
Determining whether a Flutter file or declaration is truly dead is hard because analyzer warnings alone are insufficient; code may be referenced indirectly through routes, DI, exports, or platform-specific imports.
Результат
The tool provides a structured, review-first workflow that separates mechanical evidence from human judgment, enabling safe removal of dead code while avoiding accidental deletions.
Рабочий процесс
- Run the audit mode to generate a list of candidate dead code based on analyzer diagnostics, reachability, symbol searches, and framework checks.
- Review candidates in small groups, assigning each a decision: remove, retain, or defer.
- Apply cleanup only to items marked remove, in small batches, followed by analyzer and test verification.
- After cleanup, run behavior-oriented tests to ensure no functionality was unintentionally affected.
Доказательства
Finding an unused_element warning is easy. Deciding whether a file is safe to delete is not.
The skill uses four stages: Audit, Review, Cleanup, Tests.
The result is a list of candidates, not an automatic deletion list.
Cleanup is allowed only for candidates explicitly approved as remove.
- Дата записи: 2026-11-04T00:13:48.990Z