letsar / local_hero

A widget which implicitly launches a hero animation when its position changed within the same route.
MIT License
208 stars 48 forks source link

[Widgets are swapped] : Using this with different types of widgets produces weird result. #3

Closed bimsina closed 2 years ago

bimsina commented 3 years ago

Let me know if I am missing something, but when I try to move between two different types of widgets, the widgets to be rendered is swapped in the next transition.

Top Widget ``` Container( key: ValueKey(tile), child: LocalHero( tag: tile.text, child: GestureDetector( onTap: () { setState(() { colTiles.add(tile); rowTiles.remove(tile); }); }, child: Container( color: tile.color, height: 60, width: 60, child: Padding( padding: const EdgeInsets.all(16), child: CircleAvatar( backgroundColor: Colors.white70, foregroundColor: Colors.black54, child: Text(tile.text), ), ), ), ), ), ) ```
Bottom Widget ``` Container( key: ValueKey(tile), child: LocalHero( tag: tile.text, child: GestureDetector( onTap: () { setState(() { rowTiles.add(tile); colTiles.remove(tile); }); }, child: Container( width: 80, height: 80, color: tile.color, ), ), ), ) ```

So basically the top widget has text and the bottom doesn't.

The issue is TopWidget is rendered in the bottom column in the next transition if the item was previously a part of the top row.

Here is the code if you want to test it out yourself.

kitsuniru commented 1 year ago

how's u fixed that?