Skip to content

@string

Declares a named string value resource.

Declaration

<resources xmlns="https://xwidget.dev/values">
    <string name="app_title">XWidget Demo App</string>
    <string name="welcome_message">Welcome to XWidget!</string>
    <string name="empty_state">No items found</string>
</resources>
Attribute Description Required
name Unique key for the value Yes

The string value is the text content of the element. Leading and trailing whitespace is preserved.

Fragment Usage

Reference with the @string/ directive:

<Text data="@string/app_title"/>
<Text data="@string/welcome_message"/>

Dart Usage

final title = Resources.instance.getString("app_title");

Throws an exception if the resource name is not found.

See Also