inspect 0.0.1 copy "inspect: ^0.0.1" to clipboard
inspect: ^0.0.1 copied to clipboard

Dart 1 only

Dart inspect helps you easily get information about the current executed code (class, method, line, file), private declarations and Dart VM.

example/example.dart

import "dart:async";
import "package:inspect/inspect.dart";

void main() {
  inspectPlatform();
  inspectPrivate();
  inspectStack();
}

void inspectPlatform() {
  printTitle("Dart platform");

  var isBrowser = DartPlatform.isBrowser;
  var scriptRoot = DartPlatform.scriptRoot;
  var packageRoot = DartPlatform.packageRoot;
  var uri = Uri.parse("package:inspect/inspect.dart");
  var resolvedPath = DartPlatform.resolvePackageUri(uri);

  print("isBrowser    : $isBrowser");
  print("scriptRoot   : $scriptRoot");
  print("packageRoot  : $packageRoot");
  print("package uri  : $uri");
  print("resolved path: $resolvedPath");
}

void inspectPrivate() {
  printTitle("Dart private");

  var type = new List().runtimeType;
  var typeName = DartPrivate.getTypeName(type);
  var uri = DartPrivate.getLibraryUri(type);
  var privateKey = DartPrivate.getPrivateKey(uri);

  print("type       : $type");
  print("type name  : $typeName");
  print("library uri: $uri");
  print("pivate key : $privateKey");

  if (DartPrivate.eval != null) {
    print("");

    var eval = DartPrivate.eval;
    var expr = "(x, y) => x + y";
    var x = 10;
    var y = 20;
    var func = DartPrivate.eval(expr, null);
    var result = func(x, y);

    print("expression : $expr");
    print("evaluate   : ($x, $y)");
    print("result     : $result");
  }
}

void inspectStack() {
  printTitle("Dart stack");

  var frame = new DartStack().getFrame(1);
  var raw = frame.raw;
  var source = frame.source;
  var file = frame.file;
  var lineNumber = frame.lineNumber;
  var caller = frame.caller;
  var typeName = frame.typeName;
  var methodName = frame.methodName;
  var isClosure = frame.isClosure;

  print("frame      : $raw");
  print("source     : $source");
  print("file       : $file");
  print("line number: $lineNumber");
  print("caller     : $caller");
  print("type name  : $typeName");
  print("method name: $methodName");
  print("is closure : $isClosure");
}

void printTitle(String title) {
  print("");
  print("=========================");
  print("Inspect: $title:");
  print("=========================");
}
0
likes
35
points
10
downloads

Publisher

unverified uploader

Weekly Downloads

Dart inspect helps you easily get information about the current executed code (class, method, line, file), private declarations and Dart VM.

Homepage

License

BSD-3-Clause (license)

Dependencies

path

More

Packages that depend on inspect