What im trying to do is have a pageview widget that is outputting items from a list. in this case lets just say its a list of containers. What I want to do is for when the end of the list reached is there a way to detect that final swipe and update the list and add it to the page view?
Related
I'm developing an app in Flutter, and I'm stuck with this: I have a list of widgets that I generate dynamically. When I press a button, I need to show or hide one of the widgets in the list. I use the Visible widget to show or hide them.
The problem is that I need to know how to update any of the specific widgets in my widget list as they are dynamic and are separated, it is getting complicated doing int programmatically.
How can I do it?
PS: I have the same app developed in Android Studio and I do it by traversing for example the child Views of a LinearLayout and then I ask for its id programmatically.
I am currently trying to create something like a TabBar. I created a horizontal ListView which should work as the TabBar and I my goal is, that one row fills itself with a list that contains the cards for the Tab I clicked on and refreshes when I click on another one. Is there a way to do that? It should look like this:
Reference Picture
Did you look at Work with tabs, an introduction to TabBar, TabBarView and DefaultTabController?
You could also create it from scratch using a ListView with a Card wrapped in a GestureDetector or a ListTile, and detect taps on onTap, which would set the selected data and update state using setState.
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.
I've been able to get this to work while dragging a ListItem around in a ListView. With each ListItem wrapped as a DragTarget I update attributes of the 'candidates[0]' & trigger a screen refresh. This moves the "selected" list tile (selected via childWhenDragging) to each listtile as I pass over a dragtarget.
The goal is to drag between tabs though. Currently I can select an item, then use another finger to switch tabs, then switch back to the original tab. This keeps the item on the first tab selected using childWhenDragging. However, if I switch tabs and swap with an item there, between tabs, the swap works but I am losing the childWhenDragging "selection".
This did have to add AutomaticKeepAliveClientMixin to the item being dragged to keep things working between tabs... not sure why the childWhenDragging quits working when I swap with item on 2nd tab.
At the moment I'm using a single array of Items as a class { int tab, int order, Widget child } & choose what to display per tab based on the tab/order attributes.
Adding 'addAutomaticKeepAlives' to the ListViews didn't help. Ideas?
I have successfully built my CustomScrollView() that contains SliverGrid() items and SliverPersistentHeaders() which are pinned. I want a click on any SliverPersistentHeader() to scroll to the exact position. I want to know if this is possible in flutter.