Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

'for_each' function is not sharing global registry #420

@oscar-penelo

Description

@oscar-penelo

Describe the bug
When using the for_each function and templates, any action defined in that template (for example, an onPressed handler on a button) is not interacting with global registry so we can't execute actions that interact with registry like 'set_value' or 'navigate_to'.

If the same async action is defined directly on the widget (without using a template / for_each), it works as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Define a template that uses for_each to build a list of buttons, where each button has an async onPressed action. For example:
{
    "type": "set_value",
    "args": {
        "values": {
            "template": {
                "type": "elevated_button",
                "args": {
                    "child": {
                        "type": "text",
                        "args": {
                            "text": "${key}"
                        }
                    },
                    "onPressed": "${set_value('myvalue','value:'+value['id'])}"
                }
            },
            "myvalue": "INITIAL",
            "array": [
                {"id": "1"},
                {"id": "2"},
                {"id": "3"}
            ]
        },
        "child": {
            "type": "column",
            "args": {
                "children": [
                    {
                        "type": "text",
                        "listen": [
                            "myvalue"
                        ],
                        "args": {
                            "text": "${'value: ' + myvalue}"
                        }
                    },
                    {
                        "type": "column",
                        "args": {
                            "children": "${for_each(array,'template')}"
                        }
                    }
                ]
            }
        }
    }
}

Expected behavior
Any sync or async action inside template should work

PR
for_each_pr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions