[Question] How do I find the current zoom level of an InteractiveViewer? #5969
Unanswered
arthur-tacca
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question
How do I find the current zoom level of an
InteractiveViewer? Ideally, also I'd like to know to know the current pan (displacement).For context: I'm using this for a
Canvaswhich contains some elements that I want to be scale invariant e.g. some border widths and some text labels. I plan to set their size to 1/(current zoom) when the zoom changes – they'll scale wrong momentarily but then "pop" back to their correct size, which I think will look ok. I know I could use aGestureDetectorto handle pan/zoom but it would be hard to rebuild all the functionality myself (especially momentum when panning), and doing it on the Python side will be much laggier thanInteractiveViewerwhich is a native Dart control.Here are some ideas I've thought about:
save_state()/restore_state()methods, but unfortunately they just save/load the transformation in a private variable, and it happens on the Flutter/Dart side so it really is inaccessible. (It's a bit of a missed opportunity as, aside from not helping here, it's also less flexible and more bug prone for its intended purpose than just exposing the transformation).Stackinside it and comparing its actual position and size to its original one? But I don't know enough about Fleet to know if that's feasible.Does anyone know how to do this? Thanks!
Code sample
No response
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions