Hi
Sorry for the long post. I am new to Flutter and Dart, so I am trying to give a bit of context so people can understand the ravings of a newbie!
I am building a (non game) app (for all platforms) to render S-57 navigation charts. The app has two distinct parts:
- a regular UI with dialogs, buttons, text fields, blah blah
- a low level renderer to display the charts (the charts are not tile based, but use polygon, line, and point geometries)
The chart renderer needs to be:
- fast (ish?) – I have to render a lot of polygons (I can triangulate them), and as users navigate the map, re-compute new polygons and re-render them
- embedded within the app as some sort of drawable surface widget (so not in a separate window – think of a Canvas node in Swing/JavaFx/HTML)
I am not sure how the embedding of the chart renderer part will work in Flutter.
I have done this kind of thing in other UI toolkits before, doing one of two things:
- using a “canvas-like” widget from the toolkit, which usually doesn’t give great performance because the “canvas” is too far abstracted from the GPU (e.g. usually using (semi) immediate mode rendering, no shaders, etc)
- hacking together two UI rendering loops, one for the UI part and one for the low level renderer (usually OpenGL), and this was ugly-as and fragile.
[I should have added here that I do not necessarily need an OpenGL style game loop. Happy to redraw my map when Flutter decides the UI needs redrawing in response to events]
Reading the Flutter docs I get the impression that things might be different in Flutter, and that combining the two parts of my app might be relatively easy in Flutter.
So I have two direct UI questions:
- is https://api.flutter.dev/flutter/dart-ui/Canvas-class.html the Flutter Canvas widget (if it’s fast enough then it will do fine)?
- is there some kind of lower level drawing surface that I can use in a widget in my app? It looks like there is since I see things like FragmentShader classes, but I am not sure where to start …
Finally one other question about power consumption on mobile. If the Flutter engine/run-time is re-rendering the scene every “OpenGL-ish tick”, then on mobile this is going to kill the battery. But I am guessing it doesn’t do this?
thanks and again sorry for the giant post.
CW