dart:developer library Null safety

Interact with developer tools such as the debugger and inspector.

This library is platform dependent and has separate implementations for both web and the Dart VM. A specific platform may not support all operations.

To use this library in your code:

import 'dart:developer';

Classes

Counter
A changing value. Initial value is 0.0.
Flow
A class to represent Flow events.
Gauge
A measured value with a min and max. Initial value is min. Value will be clamped to the interval [min, max].
Metric
Abstract Metric class. Metric names must be unique, are hierarchical, and use periods as separators. For example, 'a.b.c'. Uniqueness is only enforced when a Metric is registered. The name of a metric cannot contain the slash ('/') character.
Metrics
Register and deregister custom Metrics to be displayed in developer tooling.
Service
Access information about the service protocol and control the web server that provides access to the services provided by the Dart VM for debugging and inspecting Dart programs.
ServiceExtensionResponse
A response to a service protocol extension RPC.
ServiceProtocolInfo
Service protocol is the protocol that a client like the Observatory could use to access the services provided by the Dart VM for debugging and inspecting Dart programs. This class encapsulates the version number and Uri for accessing this service.
Timeline
Add to the timeline.
TimelineTask
An asynchronous task on the timeline. An asynchronous task can have many (nested) synchronous operations. Synchronous operations can live longer than the current isolate event. To pass a TimelineTask to another isolate, you must first call pass to get the task id and then construct a new TimelineTask in the other isolate.
UserTag
A UserTag can be used to group samples in the DevTools CPU profiler.

Properties

extensionStreamHasListener bool
Whether the "Extension" stream currently has at least one listener.
read-only
reachabilityBarrier int
Current reachability barrier state.
read-only

Functions

debugger({bool when = true, String? message}) bool
If when is true, stop the program as if a breakpoint were hit at the following statement.
getCurrentTag() UserTag
Returns the current UserTag for the isolate.
inspect(Object? object) Object?
Send a reference to object to any attached debuggers.
log(String message, {DateTime? time, int? sequenceNumber, int level = 0, String name = '', Zone? zone, Object? error, StackTrace? stackTrace}) → void
Emit a log event.
postEvent(String eventKind, Map eventData) → void
Post an event of eventKind with payload of eventData to the "Extension" event stream.
registerExtension(String method, ServiceExtensionHandler handler) → void
Register a ServiceExtensionHandler that will be invoked in this isolate for method. NOTE: Service protocol extensions must be registered in each isolate.

Typedefs

ServiceExtensionHandler = Future<ServiceExtensionResponse> Function(String method, Map<String, String> parameters)
A service protocol extension handler. Registered with registerExtension.
TimelineAsyncFunction = Future Function()
TimelineSyncFunction<T> = T Function()
A typedef for the function argument to Timeline.timeSync.