Skip to content

<List>

Overview

The <List> component creates a Dart List from its child elements. Each child element becomes an item in the list, providing a declarative way to construct lists within your XML markup. Use <Item> to add a non-widget value: it contributes its value attribute (which supports EL expressions) to the list — it has no text-content form.

Attributes

List

Name Type Description Required Default
innerLists String Controls how nested lists are handled. Set to "spread" to flatten inner lists No null
for String The name of the parent's attribute that will be assigned this component No null
visible bool Controls visibility of the element No true

Item

Name Type Description Required Default
value dynamic The value to add to the list. Supports EL expressions. No null
for String The name of the parent's attribute that will be assigned this component No null
visible bool Controls visibility of the element No true

Examples

Basic List

<List>
    <Item value="Apple"/>
    <Item value="Banana"/>
    <Item value="Cherry"/>
</List>

List with Dynamic Values

<List>
    <Item value="${user.firstName}"/>
    <Item value="${user.lastName}"/>
    <Item value="${user.email}"/>
</List>

List of Widgets

<List>
    <Text data="Header"/>
    <Divider/>
    <Text data="Content goes here"/>
</List>

Conditional Items

<List>
    <Item value="Always visible"/>
    <Item value="Admin only" visible="${user.isAdmin}"/>
    <Item value="Premium feature" visible="${user.isPremium}"/>
</List>

Spreading Inner Lists

<!-- Without spread: [['a', 'b'], 'c', ['d', 'e']] -->
<List>
    <Item value="${listA}"/>
    <Item value="c"/>
    <Item value="${listB}"/>
</List>

<!-- With spread: ['a', 'b', 'c', 'd', 'e'] -->
<List innerLists="spread">
    <Item value="${listA}"/>
    <Item value="c"/>
    <Item value="${listB}"/>
</List>

See Also

  • <Map> - Create key-value maps
  • <forEach> - Iterate over lists
  • <forLoop> - Numeric iteration
  • <var> - Declare variables