Sitemap
Flutter

Flutter is Google's UI framework for crafting high-quality native interfaces on iOS, Android, web, and desktop. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source. Learn more at

Dart & Flutter DevTools Extensions

10 min readNov 15, 2023

--

Example DevTools extension for package:foo

How do DevTools extensions work?

What types of tools are supported?

Writing a DevTools extension: a step-by-step guide

Before you get started

Step 1: Set up your package hierarchy

Standalone extensions

my_new_tool
extension/
devtools/
build/
... # pre-compiled output of the Flutter web app under lib/
config.yaml
lib/ # source code for your extension Flutter web app
src/
...
flutter create --template app --platforms web my_new_tool

Companion extensions

foo/  # formerly the repository root of your pub package
packages/
foo/ # your pub package
extension/
devtools/
build/
... # pre-compiled output of foo_devtools_extension/lib
config.yaml
foo_devtools_extension/
lib/ # source code for your extension Flutter web app

Step 2: Configure your extension

foo/
extension/
lib/
...
extension/
devtools/
build/
config.yaml
name: foo
version: 0.0.1
issueTracker: <link_to_your_issue_tracker.com>
materialIconCodePoint: '0xe0b1'
requiresConnection: true # optional field - defaults to true
DevTools extension screen title bar
DevTools extension tab icon

Step 3: Build your extension

flutter create --template app --platforms web foo_devtools_extension
flutter pub add devtools_extensions
flutter pub add devtools_app_shared
import 'package:devtools_extensions/devtools_extensions.dart';
import 'package:flutter/material.dart';

void main() {
runApp(const DevToolsExtension());
}

class FooDevToolsExtension extends StatelessWidget {
const FooDevToolsExtension({super.key});

@override
Widget build(BuildContext context) {
return const DevToolsExtension(
child: Placeholder(), // Build your extension here
);
}
}

Step 4: Debug your extension

Option A: Use the Simulated DevTools Environment (recommended for development)

Debugging an extension with the Simulated DevTools Environment
{
...
"configurations": [
...
{
"name": "foo_devtools_extension + simulated environment",
"cwd": "packages/foo_devtools_extension",
"request": "launch",
"type": "dart",
"args": [
"--dart-define=use_simulated_environment=true"
],
},
]
}
flutter run -d chrome - dart-define=use_simulated_environment=true

Option B: Use a real DevTools environment

cd your_extension_web_app;
flutter pub get;
dart run devtools_extensions build_and_copy --source=. --dest=path/to/your_pub_package/extension/devtools
cd your_extension_web_app;
flutter pub get;
dart run devtools_extensions validate --package=path/to/your_pub_package
DevTools Extensions menu button
DevTools Extensions menu

Step 5: Publish your package with a DevTools extension

cd your_extension_web_app;
flutter pub get;
dart run devtools_extensions validate --package=path/to/pkg_providing_your_extension_assets
cd your_extension_web_app;
flutter pub get;
dart run devtools_extensions build_and_copy --source=. --dest=path/to/your_pub_package/extension/devtools

Conclusion

Flutter
Flutter

Published in Flutter

Flutter is Google's UI framework for crafting high-quality native interfaces on iOS, Android, web, and desktop. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source. Learn more at

Kenzie Davisson
Kenzie Davisson

Written by Kenzie Davisson

Lead for the Flutter DevTools team at Google

Responses (2)