addWidgetNode method
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),
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,
),
);
}