Skip to content

UI not updated if set state action is triggered by a custom widget action #1530

@kium-one

Description

@kium-one

Has your issue been reported?

  • I have searched the existing issues and confirm it has not been reported.
  • I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.

Current Behavior

I set up a custom widget with an action as parameter. The action on the page is configured to update a widget/component state. When the action is called, the state is updated but the UI is not refreshed (conditional visibility based on the state). It's only when I click anywhere on the page that the UI suddenly refreshes.
Tested on iOS simulator + real device (iPhone).

I tried adding an extra alert when the custom widget calls the action, and got this in the console.

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: setState() or markNeedsBuild() called during build.
This Overlay widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
The widget on which setState() or markNeedsBuild() was called was:
Overlay-[LabeledGlobalKey#07d7b]
The widget which was currently being built when the offending call was made was:
ValueListenableBuilder
#0 Element.markNeedsBuild. (package:flutter/src/widgets/framework.dart:4651:9)
#1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4663:6)
#2 State.setState (<…>
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 2928 pos 18: '!navigator._debugLocked': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2 _RouteEntry.handlePush. (package:flutter/src/widgets/navigator.dart:2928:18)
#3 TickerFuture.whenCompleteOrCancel.thunk (package:flutter/src/scheduler/ticker.dart:420:15)

#4 TickerFuture.whenCompleteOrCancel.thunk (package:flutter/src/scheduler/ticker.dart:419:5)

image

Expected Behavior

Custom function actions rebuilding the page properly.

Steps to Reproduce

  1. Create a custom widget
  2. Add an action to the widget's parameters
  3. Write code to trigger the action after a 5 seconds delay
  4. Create a component or page with the custom widget
  5. Configure the custom widget's action to set some page state boolean to true
  6. Create a conditional visibility on the custom widget itself based on the page state, so that the widget is hidden as soon as the boolean is set to true.
  7. Run application on iOS simulation or real device.

Reproducible from Blank

  • The steps to reproduce above start from a blank project.

Bug Report Code (Required)

IT4ghc/lvJdOm99J1aX2de9VvCkQJmU1a5c0sd4bGA0dCJzuPLMQdvWkP1hBZ8vkTVVbPkSmmnoxpdrQid7LFu1fYEuYbKZfzZZcTg3dcz+mUZOBEpO3dkB6EelMJ2qZ0MKJryVBIsB0SHga6mWPe+vIUXTAJLL2ImdISq/LZO4=

Context

Making an audio player call an action when the playback completes.

Visual documentation

Screen.Recording.2023-09-26.at.2.05.33.PM.mov

Additional Info

No response

Environment

- FlutterFlow version: 4.0 sep 20
- Platform: iOS
- Browser name and version: Chrome Version 116.0.5845.179
- Operating system and version affected: MacOS 13.5.2 (22G91) simulator

Metadata

Metadata

Labels

status: needs triageA potential issue that has not been confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions