Viewing version 4.0.0. Open the latest package page.
dtd
4.0.0A package for communicating with the Dart Tooling Daemon.
Readme
package:dtd
A package for communicating with the Dart Tooling Daemon.
What is the Dart Tooling Daemon?
The Dart Tooling Daemon is a long-running process meant to facilitate communication between Dart tools and minimal file system access for a Dart development workspace.
When writing or running a Dart or Flutter application, in an IDE, the Dart Tooling Daemon is started by the IDE. It persists over the life of the IDE's workspace.
When running a Dart or Flutter application from the command line, the Dart Tooling Daemon is started by the DevTools server, which is owned by the Dart or Flutter command line runner. It will persist for the life of the application's run process.
Quick Start
import 'package:dtd/dtd.dart';
/// Since the Dart Tooling Daemon exists within the context of a development
/// environment, any tool using DTD can expect a development environment to
/// exist. This development environment can be an IDE session or a command line
/// run process.
///
/// To develop tools that use package:dtd to connect to the Dart Tooling Daemon,
/// you must have a real DTD instance to interact with. To get the URI of a
/// real DTD instance, you will need to simulate the development environment of
/// a user of your tool. Use one of the following methods:
///
/// 1) Open a Dart or Flutter project in an IDE workspace. The supported IDEs
/// include Android Studio / IntelliJ or VS Code. This simulates how your user
/// may be writing code or running a Dart or Flutter app, and then using your
/// tool. The IDE will automatically start DTD, and you can copy the URI to use
/// for developing your tool.
///
/// From Android Studio / IntelliJ, go to Help > Find Action > Copy DTD URI to
/// Clipboard from VS Code, use the "Dart: Copy DTD URI to Clipboard" command
/// from the command palette
/// 2) Run a Dart or Flutter application from the command line with the
/// --print-dtd flag. This simulates how your user may be running an app from
/// the terminal, and then using your tool. A DTD URI will be printed to CLI,
/// and you can copy that to use for developing your tool.
final dtdUri = 'ws://127.0.0.1:62925/';
final client = await DartToolingDaemon.connect(dtdUri);
client can then be used to interact with the Dart Tooling Daemon.
See the Examples for details on the built-in interactions.
Examples
FileSystem service example
This example shows how to access the file system through the Dart Tooling Daemon.
See dtd_file_system_service_example.dart
Service Method Example
This example shows how to set up your own service method callbacks through the Dart Tooling Daemon.
Stream Example
This example shows how to send and listen for stream events, through the Dart Tooling Daemon.
Changelog
4.0.0
- Breaking Change: rename
EventParametersconstants toDtdParameters. - Breaking Change: delete the
kFileSystemServiceNameconstant in favor ofFileSystemServiceConstants.serviceName. - Breaking Change: delete the
kUnifiedAnalyticsServiceNameconstant in favor ofUnifiedAnalyticsServiceConstants.serviceName. - Added
CoreDtdServiceConstantsandFileSystemServiceConstantsfor shared use among DTD clients.
3.0.0
- Added
ConnectedAppServiceto store the connections to Dart and Flutter applications that DTD is aware of. - Log exceptions from invalid
streamNotifyevents. - Added
getRegisteredServicesAPI. - Added new response types
RegisteredServicesResponseandVmServicesResponse. - Breaking Change: Changed the
serviceNameparameter for theDartToolingDaemon.callmethod to have typeString?instead ofString. - Breaking Change: When the
paramsparameter for theDartToolingDaemon.callmethod is null, pass the null value along to the client peer request instead of sending an empty Map value.
2.5.1
- Widen the dependency on
unified_analyticsto include 8.0.0.
2.5.0
- Update SDK constraints to
^3.5.0. - Add
isClosedgetter toDartToolingDaemon.
2.4.0
- Bump
unified_analyticsdependency to ^7.0.0.
2.3.0
- Indicate compatibility with
package:web_socket_channel2.x and 3.x. - Bump minimum version for
package:unified_analyticsto 6.1.0. DartToolingDaemon.connectwill now wait for the web socket to be connected.- The
DartToolingDaemonconstructor is now public and can be directly called with aStreamChannel<String>. - The
paramsparameter inDartToolingDaemon.call()has been changed fromMap<String, Object>?toMap<String, Object?>?. registerServicenow allows passing aMap<String, Object?>? capabilitiesthat can be supplied to clients via newServiceRegisteredandServiceUregisteredevents on theServicestream (when connected to a version of DTD that supports these streams).- Calling
DartToolingDaemon.onEvent()now returns a broadcast stream. This means multiple listeners can be added, but also means you must add a listener prior to callingstreamListento avoid the possibility of missing events.
2.2.0
- Added new response types
Success,StringResponse,BoolResponse, andStringListResponse. - Added contributing guide (
CONTRIBUTING.md).
2.1.0
- Added
getProjectRootsAPI. - Expose constant values from
dtd.dart.
2.0.0
- Documentation improvements.
- Deprecate use of
DTDConnectionin favor ofDartToolingDaemon.
1.0.0
- Solidified interface with dart tooling daemon.
- Added FileSystem service interface.
0.0.3
- Added types to service and extension exports.
0.0.2
- Added service and extension for accessing the file system through DTD.
0.0.1
- Initial version.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'dtd:4.0.0'pubspec.yaml
name: dtd
version: 4.0.0
description: A package for communicating with the Dart Tooling Daemon.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/dtd
environment:
sdk: ^3.5.0
resolution: workspace
dependencies:
dart_service_protocol_shared: ^0.0.3
json_rpc_2: '>=3.0.2 <5.0.0'
stream_channel: ^2.1.2
unified_analytics: '>=7.0.0 <9.0.0'
web_socket_channel: '>=2.0.0 <4.0.0'
# We use 'any' version constraints here as we get our package versions from
# the dart-lang/sdk repo's DEPS file. Note that this is a special case; the
# best practice for packages is to specify their compatible version ranges.
# See also https://dart.dev/tools/pub/dependencies.
dev_dependencies:
async: any
dart_flutter_team_lints: any
path: any
test: any
test_process: any
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.0.1 | On demand | Download | 684fd443…00e693 |
| 0.0.2 | On demand | Download | b15d4216…695010 |
| 0.0.3 | On demand | Download | 749b708a…fbf662 |
| 1.0.0 | On demand | Download | 9aeacf38…bb5a69 |
| 2.0.0 | On demand | Download | 249b2545…6a01e3 |
| 2.1.0 | On demand | Download | 0d4a51ab…369fec |
| 2.2.0 | On demand | Download | 58ac5c2d…aa0d30 |
| 2.3.0 | On demand | Download | 6e4e508c…ae6b86 |
| 2.4.0 | On demand | Download | 0284e4d0…d5e183 |
| 2.5.0 | On demand | Download | b8269bc2…ff6d18 |
| 2.5.1 | On demand | Download | 14a0360d…5b993a |
| 3.0.0 | On demand | Download | af352054…4f77c7 |
| 4.0.0 | Cached · Upstream SHA-256 matched | Download | 09ddb228…b7c5d3 |
Dependencies
dart_service_protocol_shared "^0.0.3"
json_rpc_2 "\u003e=3.0.2 \u003c5.0.0"
stream_channel "^2.1.2"
unified_analytics "\u003e=7.0.0 \u003c9.0.0"
web_socket_channel "\u003e=2.0.0 \u003c4.0.0"