tryCreate static method
A renderer on device, or on this platform's GPU when that is null —
or null, after telling onUnsupported why, where there is no Flutter
GPU (see createGpuDevice) or the renderer fails to start.
String? reason;
final renderer = await Renderer3D.tryCreate(onUnsupported: (r) => reason = r);
Implementation
static Future<Renderer3D?> tryCreate({
GpuDevice? device,
void Function(String reason)? onUnsupported,
}) async {
final gpu = device ?? createGpuDevice(onUnsupported: onUnsupported);
if (gpu == null) return null;
try {
return await create(gpu);
} on Object catch (error) {
onUnsupported?.call('The 3D renderer could not start: $error');
return null;
}
}