addWidgetNode method

Future<UArNodeInfo?> addWidgetNode({
  1. required String id,
  2. required Widget child,
  3. Size size = const Size(320, 200),
  4. double width = 0.3,
  5. double pixelRatio = 3,
  6. BuildContext? context,
  7. String? anchorId,
  8. String? parentId,
  9. UArVector3 position = UArVector3.zero,
  10. UArQuaternion rotation = UArQuaternion.identity,
  11. UArBillboard billboard = UArBillboard.yAxis,
  12. bool renderOnTop = false,
  13. Duration settle = const Duration(milliseconds: 50),
})

Renders a Flutter widget into an image node — info cards, price tags, labels. width is the size in metres; height follows size's aspect.

Implementation

Future<UArNodeInfo?> addWidgetNode({
  required String id,
  required Widget child,
  Size size = const Size(320, 200),
  double width = 0.3,
  double pixelRatio = 3,
  BuildContext? context,
  String? anchorId,
  String? parentId,
  UArVector3 position = UArVector3.zero,
  UArQuaternion rotation = UArQuaternion.identity,
  UArBillboard billboard = UArBillboard.yAxis,
  bool renderOnTop = false,
  Duration settle = const Duration(milliseconds: 50),
}) async {
  final Uint8List? png = await UArWidgetRenderer.render(child, size: size, pixelRatio: pixelRatio, context: context, settle: settle);
  if (png == null) return null;
  return addNode(
    UArNode.image(
      id: id,
      source: UArSource.bytes(png, extension: "png"),
      width: width,
      anchorId: anchorId,
      parentId: parentId,
      position: position,
      rotation: rotation,
      billboard: billboard,
      renderOnTop: renderOnTop,
    ),
  );
}