Mahmoud Ashour
Mahmoud Ashour

Reputation: 327

How to make a widget rotate around another widget?

I am working on a Solar system app application , I wanted the planets to rotate around the sun , the moons to rotate around the planet. Each planet is a widget , also the sun is a widget. how to make a certain widget to rotate around another certain widget?

Upvotes: 1

Views: 241

Answers (2)

Jan
Jan

Reputation: 367

https://github.com/divyanshub024/flutter_path_animation

Here you can see how it is done, you can add all the planets and even add each planet speed of rotation around the sun, or as I did, I've speed it all up with Mercury doing 1 rotation around the sun in 1 second, from there I calculated rotation speed of all other planets in relation to Mercury (basically calculated how much slower is each planet rotating than Mercury) and multiplied it by 1000000 microseconds (1 second, used microseconds, as time objects can only be integers), so have all planets rotating in proportion to Mercury down to accuracy of microsecond. For example, Pluto (okay dwarf planet) rotates more than 1000 times slower around the sun than the Mercury.

Though there are no moons, guess, that would you need to do your self, was thinking about it, it would be fun, but I ended up on this by accident so was just playing with it for fun

Upvotes: 1

Rodrigo Bastos
Rodrigo Bastos

Reputation: 2448

You can use the stack widget to stack up your widgets

Upvotes: 0

Related Questions