Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:developer
dart:developer
description

dart:developer library

Interact with developer tools such as the debugger and inspector.

This is a specialized library intended for interacting with the Dart runtimeprogrammatically for debugging and inspection. Sample uses include advanceddebugging, and creating developer tools.

This library has platform specific implementations for Dart weband Dart Native (VM). A specific platform may not support all operations.

The functionality provided by this library is generally only availableto Dart code run in development mode, e.g.,dart run, and not in productionmode, e.g., the output ofdart compile exe.

Debugging

Thedebugger function can be used to stop the program as if a breakpointwas hit. The breakpoint will be placed right after the call todebugger.This functionality can be useful for triggering breakpoints based on logicin the code.

Example:

var counter = 0;final someInterestingValue = 1000;while (true) {  if (counter == someInterestingValue) {    // Trigger a breakpoint in the debugger.    debugger();  }  counter++;}

When executed withdart run --observe, and opened in DevTools, thedebugger will be stopped withcounter at the value1000.

Inspection

Developer tools, such as Dart DevTools, connected to the runtime systemmay allow for inspecting execution timing in a "timeline" view.The static methods ofTimeline can add extra information and timing eventsto this view.

Example:

void main() {  Timeline.timeSync('Calculation loop', () {    for (var i = 30; i < 50; i++) {      Timeline.timeSync('fib($i)', () {        fibonacci(i);      });    }  });}int fibonacci(int n) => (n < 2) ? n : fibonacci(n - 2) + fibonacci(n - 1);

When executed withdart run --observe, and opened in DevTools,the Performance tab will display a timeline containing the annotationspassed totimeSync.

Developer tools

A developer tool, like the debugger built into thedart command,may access information about the running applicationexposed by the runtime system,using theService andServiceProtocolInfo classes.

Classes

Flow
A class to represent Flow events.
NativeRuntime
Functionality available on the native runtime.
Service
Access information about the service protocol and control the web serverthat provides access to the services provided by the Dart VM fordebugging and inspecting Dart programs.
ServiceExtensionResponse
A response to a service protocol extension RPC.
ServiceProtocolInfo
Service protocol is the protocol that a client like the Observatorycould use to access the services provided by the Dart VM fordebugging and inspecting Dart programs. This class encapsulates theversion 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 thanthe current isolate event. To pass aTimelineTask to another isolate,you must first callpass to get the task id and then construct a newTimelineTask in the other isolate.
UserTag
A UserTag can be used to group samples in theDevTools CPU profiler.

Properties

extensionStreamHasListenerbool
Whether the "Extension" stream currently has at least one listener.
no setter
reachabilityBarrierint
Current reachability barrier state.
no setter

Functions

addHttpClientProfilingData(Map<String,dynamic>requestProfile)→ void
Records the data associated with an HTTP request for profiling purposes.
debugger({boolwhen =true,String?message})bool
Ifwhen is true, stop the program as if a breakpoint were hit at thefollowing statement.
getCurrentTag()UserTag
Returns the currentUserTag for the isolate.
getHttpClientProfilingData()List<Map<String,dynamic>>
Returns the data added throughaddHttpClientProfilingData.
inspect(Object?object)Object?
Send a reference toobject to any attached debuggers.
log(Stringmessage, {DateTime?time,int?sequenceNumber,intlevel =0,Stringname ='',Zone?zone,Object?error,StackTrace?stackTrace})→ void
Emit a log event, which can can viewed using the DevToolsLogging view.
postEvent(StringeventKind,MapeventData, {Stringstream ='Extension'})→ void
Post an event ofeventKind with payload ofeventData to the "Extension"event stream.
registerExtension(Stringmethod,ServiceExtensionHandlerhandler)→ void
Register aServiceExtensionHandler that will be invoked in this isolateformethod.NOTE: Service protocol extensions must be registeredin each isolate.

Typedefs

ServiceExtensionHandler=Future<ServiceExtensionResponse> Function(Stringmethod,Map<String,String>parameters)
A service protocol extension handler. Registered withregisterExtension.
TimelineAsyncFunction=Future Function()
TimelineSyncFunction<T>= T Function()
A typedef for the function argument toTimeline.timeSync.
  1. Dart
  2. dart:developer
DartSDK
  1. Libraries
  2. Core
  3. dart:async
  4. dart:collection
  5. dart:convert
  6. dart:core
  7. dart:developer
  8. dart:math
  9. dart:typed_data
  10. VM
  11. dart:ffi
  12. dart:io
  13. dart:isolate
  14. dart:mirrors
  15. Web
  16. package:webopen_in_new
  17. dart:js_interop
  18. dart:js_interop_unsafe
  19. Web (Legacy)
  20. dart:html
  21. dart:indexed_db
  22. dart:js
  23. dart:js_util
  24. dart:svg
  25. dart:web_audio
  26. dart:web_gl
dart:developer library

[8]ページ先頭

©2009-2025 Movatter.jp