3

I am new to Flutter. I want to place some text that will have values changing over a Rive animation. What is the best way to make sure that the text stays in the same place over the animation no matter the screen size?

Lets say these 3 red boxes have some telemetry data as an example.

enter image description here

Will the Stack widget with position work? Before I go down this rabbit hole I think I need some advice on how to show data in or over a Rive animation.

Jaco Fourie
  • 112
  • 3
  • 11
  • Were you able to make the widgets inside the stack responsive ? My text widget does not always align the way I want it. Did you find any solution for it ? – Ramji Feb 11 '23 at 03:26

1 Answers1

1

Well, Stack is always the answer :) Wrap the Rive animation with it, and use a text widget wherever you want.

esentis
  • 4,190
  • 2
  • 12
  • 28
  • Well if I try that and I run the same app on a tablet that shows the text at the correct place on the phone then the text is not at the same spot. – Jaco Fourie Aug 23 '21 at 19:15
  • Can I fix the Rive Animation to be a certain size so the text wont move? – Jaco Fourie Aug 23 '21 at 19:16
  • Responsiveness can be achieved through various ways. There isn't a silver bullet afaik. You can try wrapping the `Stack` to `SizedBox` with your custom dimensions, then wrap `Rive` animation with `Positioned.fill` widget so it takes up the whole `Stack` and last, wrap the `Text` widget with `Positioned` to determine its position in the `Stack`. – esentis Aug 23 '21 at 19:28
  • 1
    So I first placed a container and gave it a size. This seems to work more or less. as it gives the Rive animation the same size on all the different devices. I will design the Animation in such a way so there is a bit of play. But at least I have an idea what to do. Thanks for the info. – Jaco Fourie Aug 23 '21 at 20:22
  • @Jaco Fourie, Even after wrapping widget with SizedBox and gave stack the Positioned.fill , still its not responsive. Can you educate us about how to make it responsive ? – Ramji Feb 11 '23 at 03:28