一键导入
flutter-devtools
Guide for utilizing Flutter DevTools, using visual debugging properties, and exposing custom widget states to the inspector.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guide for utilizing Flutter DevTools, using visual debugging properties, and exposing custom widget states to the inspector.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Audit and rewrite project changelogs to adhere strictly to Keep a Changelog and Semantic Versioning standards. Use when reviewing, drafting, or refining project changelogs.
Guide for utilizing the Genkit Dart SDK to build full-stack, AI-powered agentic applications.
Guide for utilizing Dart 3.0+ up to 3.12 syntax updates (private named parameters, extension types, records, pattern matching, wildcard variables, and primary constructors).
Optimize Dart code for performance, type safety, and runtime error prevention. Use when profiling hot paths, enforcing sound typing, handling null safety, or debugging type mismatches and runtime failures.
Run Dart tooling workflows for static analysis, dependency conflict resolution, and test migration to package:checks. Use when fixing analyzer errors, resolving pub dependency conflicts, or modernizing test assertions.
Configure and run integration tests using the integration_test package with Flutter Driver. Use when testing complete user flows, verifying navigation, or running end-to-end tests on devices or CI.
| name | flutter-devtools |
| description | Guide for utilizing Flutter DevTools, using visual debugging properties, and exposing custom widget states to the inspector. |
| metadata | {"platforms":"flutter","languages":"dart","category":"tooling"} |
Debugging UI, performance, and memory leaks efficiently in Flutter requires mastering the DevTools suite and utilizing framework-level debugging properties.
debugFillProperties)Start and connect DevTools to a running Flutter application:
flutter devtools in the terminal to launch the DevTools web application server.Cmd+Shift+P) and select Dart: Open DevTools.flutter run --profile) for Performance and Memory profiling. Never profile performance in Debug mode due to VM overhead.Toggle these runtime properties to visually diagnose layout and rendering performance directly on the emulator/device.
Import the rendering library to access these flags:
import 'package:flutter/rendering.dart';
import 'package:flutter/foundation.dart';
| Flag | Purpose | Usage |
|---|---|---|
debugPaintSizeEnabled = true | Visualizes layout boxes, margins, padding, and alignment. | To identify misplaced padding or sizing issues. |
debugRepaintRainbowEnabled = true | Overlays a rotating set of border colors on layers that repaint. | If a static widget changes colors on scroll, wrap it in a RepaintBoundary. |
debugPaintLayerBordersEnabled = true | Outlines the borders of individual compositor layers in orange. | Useful for debugging composite layer splits. |
debugProfileBuildsEnabled = true | Enables tracing for widget builds in the DevTools Performance timeline. | Tracks exactly which widgets are rebuilding during jank. |
debugProfilePaintsEnabled = true | Enables tracing for paint operations in the DevTools Performance timeline. | Captures heavy paint operations on custom canvases. |
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
// Toggle layout boundaries in debug mode
debugPaintSizeEnabled = true;
runApp(const MyApp());
}
debugFillProperties)When building custom widgets, design system components, or stateful widgets with complex parameters, override debugFillProperties to expose internal state variables to the Flutter Inspector's Details Tree.
debugFillProperties(DiagnosticPropertiesBuilder properties) in your Widget or State class.super.debugFillProperties(properties) first.IntProperty, DoubleProperty, StringProperty, FlagProperty, EnumProperty) to keep output clean and structured.import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class CustomButton extends StatelessWidget {
final String label;
final bool isLoading;
final int badgeCount;
const CustomButton({
super.key,
required this.label,
this.isLoading = false,
this.badgeCount = 0,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: isLoading ? null : () {},
child: Text(label),
);
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
// Add custom properties visible in Flutter Inspector
properties.add(StringProperty('label', label));
properties.add(FlagProperty('isLoading', value: isLoading, ifTrue: 'loading', ifFalse: 'ready'));
properties.add(IntProperty('badgeCount', badgeCount, defaultValue: 0));
}
}