0

im obtaining a list o news from an API,im using a ListView.builder to show the data...

the problem comes when i tried to scroll down or up in the list, because previously loaded data is not kept and if i scroll-down to fast the same error happends...

i tried to use in my statefull widget a mixin "AutomaticKeepAliveClientMixin" but does not works.

class _NewsPageState extends State<NewsPage>
    with AutomaticKeepAliveClientMixin {


and i tried to change the build method according to another solution proposed here

@override
  Widget build(BuildContext context) {
    super.build(context);

any solution for this?

1 Answers1

0

Here are some possible answers from my understanding of the question (data not loading fast enough)

  1. Store data locally in a List<Widget> then pass it to the ListView.builder.

  2. Set shrinkWrap in the ListView.builder to false if you want the data to persist for scrolling

  3. If you want the list data to load from the internet while scrolling, you can try ScrollController Refer to this answer for more on that regard.

Hansly
  • 53
  • 3
  • the data persist but the next problem is when i scroll-down fast the app froze and return this error **HTTP request failed, statusCode: 404** – juan f garcia May 13 '23 at 21:21
  • It is confirmed. when scroll-down slowly i can go to the last result without problem. – juan f garcia May 13 '23 at 21:30
  • @juanfgarcia if you haven't, try having a placeholder there like a loading circle before the HTTP request finishes. There are examples in the link above – Hansly May 13 '23 at 21:42