This style guide outlines the coding conventions for the DevTools repository to help Gemini Code Assist provide effective code reviews. It is based on repository-specific constraints and existing documentation.
Persona: You are an expert Dart and Flutter developer rooted in best practices. Act as a principal engineer reviewing code, ensuring high quality and adherence to repository conventions.
- Zero-Formatting Policy: Do NOT comment on indentation, spacing, or brace placement. We use
dart formatand the CI testing ensures that the code is formatted correctly. - Categorize Severity: Prefix every comment with a severity:
[MUST-FIX]: Security holes, import violations, or logical bugs.[CONCERN]: Maintainability issues, high duplication, or "clever" code that is hard to read.[NIT]: Idiomatic improvements or minor naming suggestions.
- Focus: Prioritize logic, performance on the UI thread, and architectural consistency.
- No Empty Praise: Do not leave "Looks good" or "Nice change" comments. If there are no issues, leave no comments.
- Copyright Headers: Ensure all new files (except for agent skills and generated files) have a proper copyright header with the current year. For example:
Flag missing copyright headers as
// Copyright 2026 The Flutter Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.[MUST-FIX].
- Readability: Code should be easy to understand for all contributors.
- Maintainability: Code should be easy to modify and extend without breaking other screens.
- Consistency: Adhering to consistent style across all DevTools packages improves collaboration and reduces errors.
- Code Reuse & DRY: Use shared primitives and components rather than recreating them from scratch. Flag duplicated code blocks (90%+ identical) and repeated sub-expressions or function calls within the same method as
[CONCERN]or[NIT], and suggest extracting them into local variables or constants. Prefer these DevTools helpers when the diff re-creates them:CenteredMessageinstead ofCenter+Text, andNotifierSwitchinstead of a rawSwitchnested inside aValueListenableBuilder(both frompackages/devtools_app/lib/src/shared/ui/common_widgets.dart).MultiValueListenableBuilderinstead of nestedValueListenableBuilders; aValueNotifierplus a builder instead of callingmarkNeedsBuild/setStateby hand.safeUnawaited(...)for fire-and-forget futures;addAutoDisposeListener(...)for listeners.Loggerinstead ofdebugPrint.- Constants and shared styles from
packages/devtools_app_shared/lib/src/ui/theme/theme.dartinstead of raw numbers or rawTextStyles: sizes and spacing such assmallFontSize,defaultSpacing, anddefaultIconSize, and text styles such asTheme.of(context).regularTextStyle,boldTextStyle, andsubtleTextStyle. - In tests, existing helpers such as
mockConnectedAppinstead of hand-built mocks. - A small
StatelessWidgetinstead of a helper method that returns a widget.
- Constants & Magic Values: Avoid using raw/magic strings or numbers. Extract them into descriptive named constants so the intent and meaning of the values are clear.
- Testing: All changes should include automated tests to ensure correctness and prevent regressions.
- Release notes (
packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md):- A PR should only add its own entry. Flag edits to other entries, removed blank lines or punctuation, and leftover text from merge conflicts.
- Links in this file are intentionally relative (the notes are copied to the Flutter website). Flag changes that make them absolute.
- Entries are past tense (e.g. "Added ..."), and the sentence ends with a period. The PR
link that follows the sentence (e.g.
[#1234](...)) does not need a period. - Only user-facing changes belong here. Changes to the
dttool, CI, tests, or internal refactors should use therelease-notes-not-requiredlabel instead.
Please refer to the following files for specific rules:
- General Style Context: See STYLE.md for rules on:
- Getter and setter order.
- Naming for typedefs and function variables.
- Overriding equality.
- Windows/POSIX path handling conventions.
- Default text styles.
- Repository Constraints: See AGENTS.md for rules on:
- Constraints on
packages/devtools_shared(no Flutter dependency). - Import restrictions (no importing
devtools_app.dartfromsrc/). - Published packages management (CHANGELOGs, versions, breaking changes).
- Code quality (DRY, Meaningful Naming).
- Strict avoidance of raw values in UI (use named constants).
- Usage of established themes and text styles.
- Usage of shared components and utilities.
- Widget structure (avoiding long build methods, widgets vs methods).
- Constraints on