You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ca525fc
Browse filesBrowse the repository at this point in the historyBrowse files
| [`null_initialized_debug_expensive_fields`](#null_initialized_debug_expensive_fields) | `ERROR` | Enabled | `packages/flutter` | Require `@_debugOnly` fields to be conditionally initialized via `kDebugMode ? <value> : null;`. |
106
+
| [`lazy_initialized_debug_expensive_fields`](#lazy_initialized_debug_expensive_fields) | `ERROR` | Enabled | `packages/flutter` | Require `@_debugOnly` fields to be lazy initialized (declared as `late final` with an initializer). |
107
107
| [`skip_test_comments`](#skip_test_comments) | `ERROR` | Enabled | Test files | Require justification comments (e.g. `// [intended]` or issue link) for skipped tests. |
108
108
| [`integration_test_timeouts`](#integration_test_timeouts) | `ERROR` | Enabled | `test_driver/` files | Require integration test files under `test_driver/` to set `timeout: Timeout.none`. |
109
109
@@ -317,11 +317,11 @@ final double width = child.getMinIntrinsicWidth(height);
317
317
318
318
---
319
319
320
-
#### `null_initialized_debug_expensive_fields`
320
+
#### `lazy_initialized_debug_expensive_fields`
321
321
- **Severity**: `ERROR`
322
322
- **Scope**: `packages/flutter`
323
-
- **Description**: Requires all fields annotated with `@_debugOnly` to be conditionally initialized via `kDebugMode ? <value> : null;`.
324
-
- **Rationale**: Expensive diagnostic objects and debug trackers must not allocate heap memory or execute costly initialization logic in profile and release builds. Initializing them with `kDebugMode ? <value> : null` enables the compiler and tree-shaker to eliminate both the field and its initializer in release builds.
323
+
- **Description**: Requires all non-static fields annotated with `@_debugOnly` to be lazy initialized (declared as `late` with an initializer).
324
+
- **Rationale**: Expensive debug fields must not allocate heap memory or execute costly initialization logic in profile and release builds. Declaring them as `late` ensures lazy evaluation on first read (which can happen only in `assert(...)` blocks).
0 commit comments