forked from flutter/devtools
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4146bf7
commit d680993
Showing
11 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/devtools_extensions/example/foo_devtools_extension/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
6 changes: 6 additions & 0 deletions
6
packages/devtools_extensions/example/foo_devtools_extension/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# foo_devtools_extension | ||
|
||
An example DevTools extension for `package:foo`. This flutter_web app `foo_devtools_extension` | ||
would be embedded inside DevTools when debugging an app that imports `package:foo`. The extension | ||
needs to be provided by `package:foo` as set forth by the requirements documented at | ||
DevTools Extensions (TODO(kenz) - write these and add a link). |
85 changes: 85 additions & 0 deletions
85
packages/devtools_extensions/example/foo_devtools_extension/lib/main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import 'package:devtools_extensions/api.dart'; | ||
import 'package:devtools_extensions/devtools_extensions.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
void main() { | ||
runApp(const FooPackageDevToolsExtension()); | ||
} | ||
|
||
class FooPackageDevToolsExtension extends StatelessWidget { | ||
const FooPackageDevToolsExtension({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const MaterialApp( | ||
title: 'Foo DevTools Extension', | ||
home: DevToolsExtension( | ||
child: FooExtensionHomePage(), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class FooExtensionHomePage extends StatefulWidget { | ||
const FooExtensionHomePage({super.key}); | ||
|
||
@override | ||
State<FooExtensionHomePage> createState() => _FooExtensionHomePageState(); | ||
} | ||
|
||
class _FooExtensionHomePageState extends State<FooExtensionHomePage> { | ||
int _counter = 0; | ||
|
||
String? _message; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
// Example of the devtools extension registering a custom handler. | ||
extensionManager.registerEventHandler( | ||
DevToolsExtensionEventType.unknown, | ||
(event) { | ||
setState(() { | ||
_message = event.data?['message'] as String?; | ||
}); | ||
}, | ||
); | ||
} | ||
|
||
void _incrementCounter() { | ||
setState(() { | ||
_counter++; | ||
}); | ||
extensionManager.postMessageToDevTools( | ||
DevToolsExtensionEvent( | ||
DevToolsExtensionEventType.unknown, | ||
data: {'increment_count': _counter}, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
backgroundColor: Theme.of(context).colorScheme.inversePrimary, | ||
title: const Text('Foo DevTools Extension'), | ||
), | ||
body: Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
Text('You have pushed the button $_counter times:'), | ||
const SizedBox(height: 16.0), | ||
ElevatedButton( | ||
onPressed: _incrementCounter, | ||
child: const Text('Increment and post count to DevTools'), | ||
), | ||
const SizedBox(height: 48.0), | ||
Text('Received message from DevTools: $_message'), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/devtools_extensions/example/foo_devtools_extension/pubspec.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: foo_devtools_extension | ||
description: A Flutter web app for the package:foo DevTools extension. | ||
publish_to: 'none' | ||
|
||
version: 1.0.0 | ||
|
||
environment: | ||
sdk: '>=3.1.0-94.0.dev <4.0.0' | ||
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
devtools_extensions: | ||
path: ../../ |
Binary file added
BIN
+917 Bytes
packages/devtools_extensions/example/foo_devtools_extension/web/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.17 KB
packages/devtools_extensions/example/foo_devtools_extension/web/icons/Icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.06 KB
packages/devtools_extensions/example/foo_devtools_extension/web/icons/Icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.46 KB
...tools_extensions/example/foo_devtools_extension/web/icons/Icon-maskable-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.5 KB
...tools_extensions/example/foo_devtools_extension/web/icons/Icon-maskable-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions
59
packages/devtools_extensions/example/foo_devtools_extension/web/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<!-- | ||
If you are serving your web app in a path other than the root, change the | ||
href value below to reflect the base path you are serving from. | ||
The path provided below has to start and end with a slash "/" in order for | ||
it to work correctly. | ||
For more details: | ||
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base | ||
This is a placeholder for base href that will be replaced by the value of | ||
the `--base-href` argument provided to `flutter build`. | ||
--> | ||
<base href="$FLUTTER_BASE_HREF"> | ||
|
||
<meta charset="UTF-8"> | ||
<meta content="IE=Edge" http-equiv="X-UA-Compatible"> | ||
<meta name="description" content=""A new Flutter project.""> | ||
|
||
<!-- iOS meta tags & icons --> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black"> | ||
<meta name="apple-mobile-web-app-title" content="foo_devtools_extension"> | ||
<link rel="apple-touch-icon" href="icons/Icon-192.png"> | ||
|
||
<!-- Favicon --> | ||
<link rel="icon" type="image/png" href="favicon.png"/> | ||
|
||
<title>foo_devtools_extension</title> | ||
<link rel="manifest" href="manifest.json"> | ||
|
||
<script> | ||
// The value below is injected by flutter build, do not touch. | ||
const serviceWorkerVersion = null; | ||
</script> | ||
<!-- This script adds the flutter initialization JS code --> | ||
<script src="flutter.js" defer></script> | ||
</head> | ||
<body> | ||
<script> | ||
window.addEventListener('load', function(ev) { | ||
// Download main.dart.js | ||
_flutter.loader.loadEntrypoint({ | ||
serviceWorker: { | ||
serviceWorkerVersion: serviceWorkerVersion, | ||
}, | ||
onEntrypointLoaded: function(engineInitializer) { | ||
engineInitializer.initializeEngine().then(function(appRunner) { | ||
appRunner.runApp(); | ||
}); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
35 changes: 35 additions & 0 deletions
35
packages/devtools_extensions/example/foo_devtools_extension/web/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "foo_devtools_extension", | ||
"short_name": "foo_devtools_extension", | ||
"start_url": ".", | ||
"display": "standalone", | ||
"background_color": "#0175C2", | ||
"theme_color": "#0175C2", | ||
"description": "A Flutter web app for the package:foo DevTools extension", | ||
"orientation": "portrait-primary", | ||
"prefer_related_applications": false, | ||
"icons": [ | ||
{ | ||
"src": "icons/Icon-192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "icons/Icon-512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "icons/Icon-maskable-192.png", | ||
"sizes": "192x192", | ||
"type": "image/png", | ||
"purpose": "maskable" | ||
}, | ||
{ | ||
"src": "icons/Icon-maskable-512.png", | ||
"sizes": "512x512", | ||
"type": "image/png", | ||
"purpose": "maskable" | ||
} | ||
] | ||
} |