Imagine I have a Stack widget that only has 3 child widgets to display user profile. And I got multiple user profile data from the server. But I wanna display only the first 3 at the moment. Then, when I swipe first top child card widget, it has to be placed bottom of the Stack widget and widget data must be updated by 4th user data and so on. How to reuse child of Stack widget like shown in the GIF image below.
PS: Sorry for my English :) and any answer would be appreciated.
You can use a List
to keep all your child widgets. Then, in the children
of the Stack
, pass only the first 3 elements of the List
containing your child widget using <insert_your_list_name>.subList(0,3)
. Every swipe event on the child widget can then remove the first element of the List
and append it to the back. Use setState
to refresh your Stack
.