<Map>
Overview
The <Map> component creates a Dart Map from its child <Entry> elements. Each entry
defines a key-value pair, providing a declarative way to construct maps within your XML markup.
Maps are useful for organizing related data and passing named parameters.
Attributes
Map
| Name | Type | Description | Required | Default |
|---|---|---|---|---|
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 |
Entry
| Name | Type | Description | Required | Default |
|---|---|---|---|---|
key |
String | The key for the map entry | Yes | - |
value |
dynamic | The value for the map entry. 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 |
* The value can be specified as a child element, the value attribute, or text content. Precedence is child element > value attribute > text content.
param
The <param> element works identically to <Entry> but uses name instead of key.
| Name | Type | Description | Required | Default |
|---|---|---|---|---|
name |
String | The key for the map entry (alternative to key) |
Yes | - |
value |
dynamic | The value for the map entry. 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 |
* The value can be specified as a child element, the value attribute, or text content. Precedence is child element > value attribute > text content.
Examples
Basic Map
<Map>
<Entry key="name" value="John Doe"/>
<Entry key="email" value="[email protected]"/>
<Entry key="age" value="${25}"/>
</Map>
Map with Text Content
<Map>
<Entry key="title">Welcome Message</Entry>
<Entry key="description">
This is a longer description
that spans multiple lines.
</Entry>
</Map>
Map with Dynamic Values
<Map>
<Entry key="userId" value="${user.id}"/>
<Entry key="userName" value="${user.firstName + ' ' + user.lastName}"/>
<Entry key="isActive" value="${user.status == 'active'}"/>
</Map>
Conditional Entries
<Map>
<Entry key="name" value="${user.name}"/>
<Entry key="email" value="${user.email}"/>
<Entry key="adminLevel" value="${user.adminLevel}" visible="${user.isAdmin}"/>
</Map>
Map with Widget Values
<Map>
<Entry key="header">
<Text data="Dashboard">
<TextStyle for="style" fontWeight="bold"/>
</Text>
</Entry>
<Entry key="content">
<Column>
<Text>Welcome back!</Text>
</Column>
</Entry>
</Map>
Nested Maps
<Map>
<Entry key="user">
<Map>
<Entry key="name" value="${userName}"/>
<Entry key="roles">
<List>
<Item value="admin"/>
<Item value="editor"/>
</List>
</Entry>
</Map>
</Entry>
<Entry key="settings">
<Map>
<Entry key="theme" value="dark"/>
<Entry key="notifications" value="${true}"/>
</Map>
</Entry>
</Map>
Using param Syntax
<Map>
<param name="title" value="Settings"/>
<param name="showBackButton" value="${true}"/>
<param name="theme" value="${currentTheme}"/>
</Map>
See Also
<List>- Create ordered collections<var>- Declare variables