how to make Lazy Scroll on listView? - android-listview

is there any way to make lazy scrolling on a list view? i want to lazy scroll till the page ends, then show next page. my list view provides items which are articles(title,teaser and a picture)
at this moment i'am downloading all what i need and making an async task + Caching to handle the images download (lazy loading).
Any idea how to do the lazy scroll for items ?
Thank You

Related

how to prevent PageView.builder building page I didnt enter yet or delete getxcontroller after I leave the page - flutter/GetXcontroller

sorry in advance if i didnt describe my question clearly:
I have several pages made by PageView.builder, while swiping these pages on main screen left and right, I found their initState is already working, and GetXController inside are also loading their data. I use Get.delete<Controller> while clicking back button and coming back to main screen to remove these data.
However, the state and data will bring back to main screen if I didnt activate Get.delete<Controller>, and therefore next time I come to this page, the state of page will be not default, for instance the button still keep pressed status.
So my question is how to prevent page.builder to build the widget before I come inside to this page, or how to delete getxcontroller if I am not in this page. Thanks a lot!
Try resetting the GetX by calling
Get.reset(); --> this will re-initialize controllers
Alternatively calling
Get.put(ControllerName()); in a build method will re-initialize the controller

Managing Nested Horizontal Lists in Flutter

So I am at a beginner level in flutter and currently ran into a blocking point , I have 2 singeltons loading 2x jsons then displaying them into my app, the blocking point is that I am currently trying to figure out if I can display the data using Nested ListViews(1 Vertical with Horizontal children).
The problem is I have 50 categories of Item Lists, I use a ListView.builder to build a list of Horizontal Lists,issue is when nesting ListView.builders the Parent ListView.builder builds all the Child lists with 4 elements each and thus there is a delay when loading the screen and when switching pages.
I cannot find a way to manage this in an elegant manner, I would like to find a way to show a loading progress indicator or similar instead of having that delay just show an empty screen, so I would appreciate any suggestions.
My current Build is something like this:
Main Screen: Column -> Widgets[
... Bunch of Widgets(),
CategoryList(),
]
where
CategoryList() is a vertical List built using:
ListView.builder of CategoryListItems()
where
CategoryListItems() is a horizontal List built using :
ListView.builder of CategoryItem() (this is basically a card with text and an Image) ,
Use FutureBuilder to show progress indicator as I am assuming that the processing is being done asynchronously. Return circular progress indicator when the task is not complete.

Flutter Webview reloads every time I switch screen

I'm making an app with a BottomNavigationBar with 5 different screens, each of them has a web view. The problem is that everytime I come back to a screen that was previously loaded, it reloads. I have tried using AutomaticKeepAliveClient from copy pasting this code but I doesn't seem to work. I'm new with Flutter so be precise please, thank you.
AutomaticKeepAliveClient is mainly used for keeping a child alive in lazily rendered list views. In your case whenever you switch tabs your current page get disposed and new page materializes on top of it, that means each time when you switch tab a new page is created including all it's widgets.
So if you want to keep your previously loaded web views alive, you have to go with either PageView widget or use Stack widget to load your pages programmatically while the user clicks on a tab.
This is a detailed example about implementing your requirement using PageView widget . you can also find an example with Stack widget under that question.

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.

Preload page content in TabBarView

I am currently using a TabBarView to display a long list of images (think picture gallery or manga reader).
It seems that each image is only loaded when I start swiping to the new page, i. e. when the edge of the new page becomes visible.
In an Android ViewPager we had setOffscreenPageLimit to be able to pre-create pages that are still off screen.
Is there a similar functionality in TabBarView or would I have to implement the preloading at a lower level, e. g. prefetching the images and caching them locally?
Bonus question: Is TabBarView even the correct widget for this use case or is there a more light weight alternative (considering I do not want simple scrolling but swiping and self-centering pages).
I don't think we currently have built-in support for preloading tabs in TabBarView. You could add it yourself, or using createLocalImageConfiguration and NetworkImage.resolve, you could cause images to be cached.