Attribute Values
XML attributes are written as strings. Generated inflaters turn those strings into the Dart values required by Flutter constructors: numbers, colors, insets, durations, enums, and other common UI types.
Use this page when you know the Dart type of an attribute and need the exact XML format to write.
Some sections list accepted strings, but those strings are parser keywords, literal formats, or Flutter constant names. Dart enum attributes are covered separately in Enum Values.
Alignment
The parser accepts these Flutter Alignment constant names for non-directional
layout positions:
topLeft, topCenter, topRight,
centerLeft, center, centerRight,
bottomLeft, bottomCenter, bottomRight
AlignmentDirectional
The parser accepts these Flutter AlignmentDirectional constant names when the
position should resolve with text direction. start and end replace physical
left and right.
<Scaffold persistentFooterAlignment="centerEnd">
<Text for="body" data="Page content" />
</Scaffold>
AlignmentGeometry
The parser accepts both physical Alignment constants and directional
AlignmentDirectional constants.
bool
Boolean values are true or false. Matching is case-insensitive.
BorderRadius and BorderRadiusGeometry
The value is a numeric shorthand that can set every corner, vertical pairs, or each corner individually.
| XML value | Result |
|---|---|
8 |
All corners use radius 8. |
8,12 |
BorderRadius.vertical(top: 8, bottom: 12). |
1,2,3,4 |
topLeft: 1, topRight: 2, bottomRight: 3, bottomLeft: 4. |
<Container>
<BoxDecoration for="decoration" borderRadius="8" />
</Container>
<Container>
<BoxDecoration for="decoration" borderRadius="4,8,12,16" />
</Container>
Color
Colors accept 6-digit RGB or 8-digit ARGB hex. The # and 0x prefixes are
optional.
| XML value | Meaning |
|---|---|
#0066CC |
Opaque RGB color. |
0066CC |
Same as #0066CC. |
0x0066CC |
Same as #0066CC. |
#800066CC |
ARGB color with alpha 80. |
800066CC |
Same as #800066CC. |
0x800066CC |
Same as #800066CC. |
Curve
The parser accepts these Flutter Curves constant names:
bounceIn, bounceInOut, bounceOut,
decelerate,
ease, easeIn, easeInBack, easeInCirc, easeInCubic, easeInExpo,
easeInOut, easeInOutBack, easeInOutCirc, easeInOutCubic,
easeInOutCubicEmphasized, easeInOutExpo, easeInOutQuad,
easeInOutQuart, easeInOutQuint, easeInOutSine,
easeInQuad, easeInQuart, easeInQuint, easeInSine, easeInToLinear,
easeOut, easeOutBack, easeOutCirc, easeOutCubic, easeOutExpo,
easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine,
elasticIn, elasticInOut, elasticOut,
fastLinearToSlowEaseIn, fastOutSlowIn,
linear, linearToEaseOut, slowMiddle
double
Double values are parsed with double.parse. The value infinity maps to
double.infinity.
Because the default config includes *:width and *:height, width and height
attributes use this parser even when the reflected Dart type is not enough to
infer it.
<SizedBox width="240" height="120" />
<SizedBox width="infinity" />
<TextStyle fontSize="14" height="1.4" />
Duration
Durations are an integer immediately followed by a unit. Do not add spaces between the number and the unit.
| Units | Meaning |
|---|---|
ms, milli, millis, milliseconds |
Milliseconds |
s, sec, secs, seconds |
Seconds |
m, min, mins, minutes |
Minutes |
h, hr, hrs, hour, hours |
Hours |
d, day, days |
Days |
<MaterialApp themeAnimationDuration="250ms">
<Text for="home" data="Home" />
</MaterialApp>
<MaterialApp themeAnimationDuration="2s">
<Text for="home" data="Home" />
</MaterialApp>
EdgeInsets and EdgeInsetsGeometry
Insets accept either one value for every side or four values in left, top, right, bottom order. Two-value shorthand is not part of the default parser.
| XML value | Result |
|---|---|
16 |
EdgeInsets.all(16). |
8,12,8,12 |
EdgeInsets.fromLTRB(8, 12, 8, 12). |
<Padding padding="16">
<Text data="All sides" />
</Padding>
<Padding padding="8,12,8,12">
<Text data="Left, top, right, bottom" />
</Padding>
Enum Values
Enum attributes use the generic enum parser generated for constructor arguments
whose Dart type is an enum. The generated parser calls parseEnum() with that
enum's .values, so the XML value must match one of the enum constant names.
<Column mainAxisAlignment="center" crossAxisAlignment="start" />
<TextStyle fontStyle="italic" overflow="ellipsis" />
<ThemeData brightness="dark" materialTapTargetSize="shrinkWrap" />
Here center maps to MainAxisAlignment.center, and start maps to
CrossAxisAlignment.start. Likewise, italic maps to FontStyle.italic, and
dark maps to Brightness.dark. The accepted values come from the enum type of
the constructor argument.
If the generated inflater XSD is registered in your editor, enum attributes show the valid options from that enum in XML completion and validation.
FontWeight
The parser accepts common names, numeric weights, and Flutter-style w###
names.
| XML values | Result |
|---|---|
thin, 100, w100 |
FontWeight.w100 |
extraLight, 200, w200 |
FontWeight.w200 |
light, 300, w300 |
FontWeight.w300 |
regular, normal, 400, w400 |
FontWeight.w400 |
medium, 500, w500 |
FontWeight.w500 |
semiBold, 600, w600 |
FontWeight.w600 |
bold, 700, w700 |
FontWeight.w700 |
extraBold, 800, w800 |
FontWeight.w800 |
black, 900, w900 |
FontWeight.w900 |
IconData
Icons are looked up by registered icon name. Generated icon names include the
icon set prefix, such as Icons.add or CupertinoIcons.cube. The default
config also parses any argument named icon or activeIcon as IconData.
InputBorder
The parser accepts these keywords:
int
Integer values are parsed with int.parse.
Key
Use the unique keyword when a fresh UniqueKey should be created. Any other
value becomes a ValueKey with that string.
| XML value | Result |
|---|---|
unique |
UniqueKey() |
| any other value | ValueKey(value) |
List<T>
List parsers split comma-separated values and trim whitespace around each item. A single value becomes a one-item list.
| Dart type | XML value | Result |
|---|---|---|
List<String> |
alpha,beta,gamma |
['alpha', 'beta', 'gamma'] |
List<double> |
1, 2.5, 3 |
[1.0, 2.5, 3.0] |
List<int> |
1, 2, 3 |
[1, 2, 3] |
<TextStyle fontFamilyFallback="Inter,Roboto,Arial" />
<LinearGradient stops="0,0.5,1" colors="${gradientColors}" />
Locale
Locales accept a language code alone or a language and country separated by an underscore. The parser lowercases the language code and uppercases the country code.
| XML value | Result |
|---|---|
en |
Locale('en', null) |
en_US |
Locale('en', 'US') |
Offset
Offsets accept one value for both axes or two values for dx and dy.
| XML value | Result |
|---|---|
8 |
Offset(8, 8) |
8,12 |
Offset(8, 12) |
<PopupMenuButton itemBuilder="${buildMenuItems}" offset="4" />
<PopupMenuButton itemBuilder="${buildMenuItems}" offset="4,12" />
Size
Sizes accept square, width-height, and unbounded forms. A missing side in the
x form becomes double.infinity.
| XML value | Result |
|---|---|
24 |
Size(24, 24) |
24x16 |
Size(24, 16) |
24,16 |
Size(24, 16) |
24x |
Size(24, double.infinity) |
x16 |
Size(double.infinity, 16) |
<SizedBox.fromSize size="24">
<Text data="Square" />
</SizedBox.fromSize>
<SizedBox.fromSize size="120x40">
<Text data="Wide" />
</SizedBox.fromSize>
String
Strings are passed through unchanged.
TextDecoration
The parser accepts these Flutter TextDecoration constant names:
TextInputType
The parser accepts these Flutter TextInputType constant names:
datetime, emailAddress, multiline, name, none, number, phone,
streetAddress, text, url, visiblePassword
VisualDensity
Visual density accepts one value for both axes or two values for horizontal and vertical density.
| XML value | Result |
|---|---|
1 |
VisualDensity(horizontal: 1, vertical: 1) |
1,2 |
VisualDensity(horizontal: 1, vertical: 2) |
<MaterialApp>
<ThemeData for="theme" visualDensity="-1" />
<Text for="home" data="Compact" />
</MaterialApp>
<MaterialApp>
<ThemeData for="theme" visualDensity="-1,0" />
<Text for="home" data="Compact horizontally" />
</MaterialApp>
WidgetStateProperty<T>
The default config can wrap these values with WidgetStateProperty.all(...):
| Dart type | XML format |
|---|---|
WidgetStateProperty<Color> |
Same as Color. |
WidgetStateProperty<double> |
A numeric double value. |
WidgetStateProperty<EdgeInsetsGeometry> |
Same as EdgeInsetsGeometry. |
WidgetStateProperty<Size> |
Same as Size. |
<ElevatedButton>
<ButtonStyle for="style"
backgroundColor="#0066CC"
elevation="2"
padding="8,12,8,12"
fixedSize="120x40" />
<Text for="child" data="Save" />
</ElevatedButton>
Custom Parsers
The formats above come from the default parser rules generated into each
inflater's parseAttribute() method. Applications can add new rules or override
existing ones in xwidget_config.yaml.
Parser lookup is ordered from most specific to most general:
ClassName:argumentName*:argumentNameArgumentType
Use a class-and-argument rule for one constructor argument, a wildcard argument
rule for a common attribute name, or a type rule for every argument of that Dart
type. The default config uses wildcard rules for *:width and *:height, so
any attribute named width or height is parsed as a double before type-based
rules are considered.
If no parser exists, the attribute value is passed through to the inflater as-is.
For a literal XML value like name="settings", that value is a String. For a
whole-attribute EL expression like value="${object}", the value can be any Dart
object, including a function.
inflaters:
constructor_arg_parsers:
"MyWidget:customProp": "parseCustomProp(value)"
"*:width": "parseDouble(value)"
"Color": "parseColor(value)"
Custom parser functions must be available to the generated inflater file through
inflaters.imports or an include file. In the config above, this XML calls
parseCustomProp(value):