Code Monkey home page Code Monkey logo

Comments (7)

demchenkoalex avatar demchenkoalex commented on May 27, 2024 2

Hi @UADACID the example is here https://docs.flyer.chat/flutter/chat-ui/advanced-usage#pagination you just need to add a boolean property, let's say _isRequesting (similarly to the example's _page) and set it to true before the request and to false after (after _page in the example).

from flutter_chat_ui.

demchenkoalex avatar demchenkoalex commented on May 27, 2024 1

Hi @gtu-myowin no, function should always be passed, otherwise chat will think there is no pagination. But inside the function, _handleEndReached, just don't fetch when _isRequesting is true, do an early exit. Chat will be trying to use _handleEndReached multiple times, but with the early exit nothing will be happening, and eventually if data will be loaded, _handleEndReached won't be triggered, cause new items will appear (will trigger again if you will continue scrolling) and if there will be an error, it will try to re-fetch again on pull.

from flutter_chat_ui.

demchenkoalex avatar demchenkoalex commented on May 27, 2024

Hi @infernowalker

Thanks you!

Of course it is being called many times, it is a developer's job to set requesting state, fire a request, update data source and set requesting to false :) only one request :)

from flutter_chat_ui.

UADACID avatar UADACID commented on May 27, 2024

Hi @infernowalker

Thanks you!

Of course it is being called many times, it is a developer's job to set requesting state, fire a request, update data source and set requesting to false :) only one request :)

any example to handle this case ?

from flutter_chat_ui.

UADACID avatar UADACID commented on May 27, 2024

https://docs.flyer.chat/flutter/chat-ui/advanced-usage#pagination

Thanks you! 😆😆😆 @demchenkoalex

from flutter_chat_ui.

gtu-myowin avatar gtu-myowin commented on May 27, 2024

Hi @demchenkoalex, I just wanted to be sure. Are you saying to fire onEndReached conditionally like this?

Chat(
	messages: _messages,
	onAttachmentPressed: _handleAtachmentPressed,
	onMessageTap: _handleMessageTap,
	onPreviewDataFetched: _handlePreviewDataFetched,
	onSendPressed: _handleSendPressed,
	showUserAvatars: true,
	showUserNames: true,
	user: _user,
	onEndReached: _isRequesting ? null : _handleEndReached, // I'm talking about this line.
	isLastPage: _isLastPage,
)

from flutter_chat_ui.

gtu-myowin avatar gtu-myowin commented on May 27, 2024

Thank you for your explanation. I will give it a try.

from flutter_chat_ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.