[Question] How do I find the current zoom level of an InteractiveViewer? #5969
-
QuestionHow do I find the current zoom level of an For context: I'm using this for a Here are some ideas I've thought about:
Does anyone know how to do this? Thanks! Code sampleNo response Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I fixed this by implementing a custom user extension that supplies the control. Then I could write whatever code I wanted on the Flutter / Dart side. The original plan was to just wrap the Flutter InteractiveViewer, like the Flet InteractiveViewer does, but add the event I wanted so I could call the callback on the Python side. But actually, I came up with a better overall solution. As I said above, I wanted the zoom callback to do a specific thing: to counterscale some elements of a Flet Canvas so they stayed constant while the overall image zoomed in or out, accepting a slight delay would cause graphical glitches (the line thickness etc. would briefly change before popping back to their original size). But I realised I could copy the whole Flet Canvas control on the Flutter side inside my custom control, and apply the counterscaling there without going through the Python, so it happens instantly. Now I have a zoomable canvas like I wanted with some scale-invariant elements and it all happens smoothly with no graphical artefacts. I think Flet has potential to be a bit of a gateway drug to pure Flutter. My custom control currently reuses the Flet Canvas interface but it's tempting to re-express it in terms of my application's abstract model and move the business logic (e.g. "this thing looks like a red oval") to the Flutter side. |
Beta Was this translation helpful? Give feedback.
I fixed this by implementing a custom user extension that supplies the control. Then I could write whatever code I wanted on the Flutter / Dart side.
The original plan was to just wrap the Flutter InteractiveViewer, like the Flet InteractiveViewer does, but add the event I wanted so I could call the callback on the Python side.
But actually, I came up with a better overall solution. As I said above, I wanted the zoom callback to do a specific thing: to counterscale some elements of a Flet Canvas so they stayed constant while the overall image zoomed in or out, accepting a slight delay would cause graphical glitches (the line thickness etc. would briefly change before popping back to their…