-
Notifications
You must be signed in to change notification settings - Fork 28
Component var updates in streaming API inside action block prepends _model. #5580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello! 😊 One important thing to keep in mind is that Action Blocks (App Block or Component Block) don’t have direct access to the model they are implemented in. This means that trying to update a component’s state directly from an Action Block will likely result in failure. Instead, you might consider using AppState, as it doesn’t require direct access to any specific model and can help you achieve the desired behavior. |
Hello Alezanello, Thank you for your response! Sorry if i'm misunderstanding how states are handled. My issue seems to be coming from trying to update a component state that is a list of a custom data type from within a streaming API call in the block, flutterflow is prepending _model. to the function when it should not be. I think this may be specific to streaming API calls which i'm trying to do. Please take a look at my code to see. If I download my code and remove the _model. manually, this solves the problem and my code will run, updating the component state. However, I get UI refresh issues, only the first chunk will display on my screen the others don't update, although all chunks are processed and stored in component state, so it can be accessed. I have now moved all the logic to AppState, which has solved my issue as you suggested. |
Hello!! |
Hey, This is basically how I do it, i'm streaming a chatGPT response into a "ChatItem" data type (which contains a 'content' field) from the server sent event JSON as a string and appending it to the previous chunk with combine text. Because i'm updating a component variable that is a list of ChatItem data on each chunk flutterflow uses the _model.updateVarAtIndex function, which would be correct if the API call was in the widget, but because it's in the component block it shouldn't be using _model. it has direct access to updateVarAtIndex. I really think this is a bug, as VS code picks up the error but flutterflow doesn't, and if I remove _model. it runs. |
This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue. |
Can we access your project?
Current Behavior
Streaming API call that is inside a component level action block will prepend "_model." to the function.
(onMessageInput) async { _model.updateVariableAtIndex(
This does not throw an error in Flutterflow but it will when pulling to VS code.
Expected Behavior
Does not need to prepend "_model." as its already inside the model.
Steps to Reproduce
Reproducible from Blank
Bug Report Code (Required)
ITFfksmBw41Pm9tc1r6Jb8BGnmYWH0ccTOURiO0bFDsdF4iuPOxzacnCXE9tYN+rTAhfKEWJhmoywdbLhtjlNPUoORKaRa0/+s5ubTzzWni/aoSxBsyNOHZQEeNWGU+P07ejuQl+ItducnMsw06uBPKicHbXHqX7Zwh9f6PHaOI=
Visual documentation
Environment
Additional Information
No response
The text was updated successfully, but these errors were encountered: