Skip to content

Commit

Permalink
Add a devtools extensions example for using DTD (flutter#7752)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll committed May 14, 2024
1 parent 7a5758f commit 39a924c
Show file tree
Hide file tree
Showing 12 changed files with 423 additions and 54 deletions.
3 changes: 3 additions & 0 deletions packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ TODO: Remove this section if there are not any general updates.
tests. - [#7717](https://github.com/flutter/devtools/pull/7717)
* Fix an issue with detecting extensions for nested Dart or Flutter
projects. - [#7742](https://github.com/flutter/devtools/pull/7742)
* Add an example to `package:devtools_extensions` that shows how to
interact with the Dart Tooling Daemon from a DevTools
extension. - [#7752](https://github.com/flutter/devtools/pull/7752)

## Full commit history

Expand Down
1 change: 1 addition & 0 deletions packages/devtools_extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Add an example of a standalone extension.
* Add examples of Dart and Flutter tests that can be ran and connected to
available DevTools extensions.
* Add an example of interacting with the Dart Tooling Daemon from a DevTools extension.

## 0.1.1
* Update the simulated environment help dialogs with information about the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import 'package:foo/foo.dart';
//
// flutter test test/ --start-paused


void main() {
testWidgets('Builds $MyAppThatUsesFoo', (tester) async {
await tester.pumpWidget(const MyAppThatUsesFoo());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2024 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

/// Header widget for each example section.
class SectionHeader extends StatelessWidget {
const SectionHeader({
required this.number,
required this.title,
this.requirements,
super.key,
});

final int number;
final String title;
final String? requirements;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'$number. $title',
style: theme.textTheme.titleMedium,
),
if (requirements != null)
Text(
requirements!,
style: theme.textTheme.titleSmall!.copyWith(
color: theme.colorScheme.tertiary,
),
),
],
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:devtools_app_shared/ui.dart';
import 'package:devtools_extensions/api.dart';
import 'package:devtools_extensions/devtools_extensions.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -45,17 +44,6 @@ class _ListeningForDevToolsEventExampleState

@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'3. Example of listening for a DevTools event',
style: Theme.of(context).textTheme.titleMedium,
),
const PaddedDivider.thin(),
Text('Received an unknown event from DevTools: $message'),
],
);
return Text('Received an unknown event from DevTools: $message');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:devtools_app_shared/ui.dart';
import 'package:devtools_extensions/api.dart';
import 'package:devtools_extensions/devtools_extensions.dart';
import 'package:flutter/material.dart';
Expand All @@ -26,11 +25,6 @@ class CallingDevToolsExtensionsAPIsExample extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'4. Example of calling DevTools extension APIs',
style: Theme.of(context).textTheme.titleMedium,
),
const PaddedDivider.thin(),
ElevatedButton(
onPressed: () => extensionManager.postMessageToDevTools(
DevToolsExtensionEvent(
Expand Down
Loading

0 comments on commit 39a924c

Please sign in to comment.