How to add a view counter in flutter - flutter

I'd like you to guide me on how I can detect if a user has seen an item so implement a view counter
as on the image below
Is there any widget I need to use to get this result? What searches do I need to do to get this result?

Related

Refresh a widget programmatically

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.

Create Vertical List in Flutter

I want to create this type of listview using flutter.
https://dribbble.com/shots/6872462-Food-ordering-app-Animate
You can find out more by clicking on this link. But I don't know how to create this type of list. I mean, you can see in the GIF that the list is indexed based.
A fixed indexed item container is colored.
How can I achieve it?
Flutter provides you with a widget very similar to the result you want to achieve called NavigationRail.
You will not have the animation by default, but you can maybe search in the source code of this widget how to create a custom widget that will implement animations.

How to implement this time picker UI in Flutter?

I am been trying to implement this time picker UI. I used SingleChildScrollView() to implement the scrolling but I am not getting it how to retrieve the data which user selects.
I used NotificationListener() but it is only notifying me where user is starting and ending the scrolling.
I want to retrieve the value where user stops. How to do that ? Click link to view UI.
enter image description here
I think you should try ListWheelScrollView class which has more appropriate design for this case and provides a callback onSelectedItemChanged. So you can retrieve desired value from it.
This widget works like a ListView with focused sections and also have some nice features for customization.

how to make changes from another screen in flutter

I'm new to Flutter and I need help with logic part for my project so if this question doesn't belong in SOF, please let me know.
So I have stacks of cards in one screen and I want to control those cards from another screen but I'm not really sure how to implement and the logic behind it so can somebody help me?.
so the idea is, The user can view stacks of cards in Home Screen but they can't reorder their position, if the user want to do that than he have to go to Reorder Screen.
Basic idea of the app will look like
Home Screen
.......................
Card 1
Card 2
Card 3
//All cards are stack together
Reorder Screen.
.........................
Button 1 (syn to Card 1)
Button 2 (syn to Card 2)
Button 3 (syn to Card 3)
it will appear in this order but the user can move their position
by drag and drop and this will also change the order of the Cards in Home Screen too,
I understand that It'll be very difficult without looking any code but please let me know how you going approach to implement this feature if you were asked to do it.
Any suggestion or help on the logic part will be really appreciated. Thanks
What you are trying to do is called state management. You state is the data which can change. The simplest option is to pass variables from the card screen to the button screen. The button screen would then make changes to this state, and pass it back. You can do this with just stateful widgets and setState. For more complicated state, you will need to use a more advanced system like the bloc pattern or providers.
For this example, you could pass the list to the list to the button screen from the card screen. The button screen modifies this list, then you use setState to apply changes to the screen. Be aware of widget keys when changing the order of items in a list.
I think that what you want is a state management solution. There is a lot of them, with each their pros and cons. I (and the Flutter team) would suggest Provider.
Basically, your Provider would hold the cards data list and a function to reorder it.
Then, both the screens would depend on that data (using a Consumer).
And the reorder screen would call something like context.read<YourProvider>().reorder(oldIndex, newIndex) to reorder the list.
Take a look at this for further details : Simple app state management
If you want to get informed about other SM solutions : List of state management approaches

How to load data on a screen on the press of a button without routing and rebuilding whole screen

Pardon me if this is a naive question but I am trying to figure out a way in Flutter to load different data when the user clicks a button. The way I currently see is routing the user to a new screen everytime but I am sure there would be a better approach without loading the whole screen everytime
You should use a Stateful Widget
I would create a Future Builder / ListView Builder. Depending on how you want it to behave you could have the ListView items clear before regenerating the list of items to show.
Future Builder you could create a function to return certain widgets depending on the request you make with the function.