printRenderObjectTree method

Future<void> printRenderObjectTree(
  1. String? routePath
)

Prints the render object tree for debugging purposes.

@param routePath Optional path to a specific route whose render tree should be printed. If null or matches initialRoute, prints the root render object tree. Otherwise prints the render tree of the specified hybrid route view.

On desktop platforms (macOS/Windows/Linux), this method also writes the render object tree to a file in the user's Documents directory (or app documents directory fallback) with a timestamp.

Implementation

Future<void> printRenderObjectTree(String? routePath) async {
  final result = await dumpRenderObjectTree(
    routePath,
    writeToFile: Platform.isMacOS || Platform.isWindows || Platform.isLinux,
    printToConsole: true,
  );
  if (result == null) {
    debugPrint('Render object tree is empty.');
    return;
  }
  if (result.savedFilePath != null) {
    debugPrint('Render object tree written to: ${result.savedFilePath}');
  }
}