(Flutter, Rive_Native) Rendering a Rive artboard to a Flutter Canvas using rive_native?
I’m trying to use rive_native to render a Rive artboard directly to a Flutter Canvas.
I was able to get the RivePlayer class from the example project into my own project, but I need much more control over the rendering. I’d like to understand if I’m supposed to be able to do something like the following:
final riveRenderer = rive.Renderer.make(canvas);
final artboard = getMyArtboardFromSomewhere();
if (artboard == null) {
throw Exception("Could not find artboard");
} else {
artboard.advance(1 / 60); // TODO: Use a real delta time
artboard.draw(riveRenderer);
riveRenderer.dispose();
}When I run this code as a macOS app (in Debug mode), I get the following assertion failure:
'package:rive_native/src/ffi/rive_ffi.dart':
Failed assertion: line 2597 pos 12:
'riveFactory.isValidRenderer(renderer)': is not true.I notice that riveRenderer is a FlutterRendererFFI, and it seems that Renderer.make(canvas) is only compatible with the old Flutter renderer—not the new native Rive renderer.
My questions:
Is there a supported way to render a Rive artboard to a Flutter Canvas using the new native renderer?
If not, is is possible to re-implement custom painting (e.g., lines, rectangles, text) using the Rive runtime itself (sort of using a “RiveCanvas” (Renderer) instead of (Flutter)Canvas)?
(I need to render multiple instances of the same artboard to the screen, in different states and mixed with some non-Rive graphics)