Text class
Textual content.
The difference over string is support for localization directives, which are in lines starting with "::".
For example, a social media post could be split into English and down-under English versions:
:: ?en
Colorful flip flops
::
:: ?en-AU ?en-NZ // Comments are also supported.
::
Colorful thongs
Different users seeing different version of the text can be dangerous, which application developers should remember when they design user interfaces. For example, a malicious user could write a nasty text in one locale and non-nasty text in another locale.
Some potential strategies to deal with danger are:
- Always show the raw string (ignore directives).
- Show a localized text, but enable users to see other locales by tapping the text.
Constructors
- Text(String value)
-
const
- Text.fromRaw(String value)
-
const
Properties
- hashCode → int
-
The hash code for this object. [...]
read-only, override
- raw → String
-
Raw string.
read-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
-
sections
→ Iterable<
TextSection> -
Returns all sections.
read-only
Methods
-
allSections(
{String separator = '\n'}) → String - Like raw, but directives have been trimmed.
-
firstLine(
{List< String> localeNames}) → String - Trims whitespace and gets only the first line.
-
get(
{List< String> localeNames}) → String - Returns the best localization. [...]
-
localizationsByName(
{String defaultLocale}) → Map< String, String> - Returns all localizations.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
A string representation of this object. [...]
override
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
override
Static Properties
-
defaultLocaleNames
↔ List<
String> -
read / write
Constants
- serializer → const Serializer
-
_TextSerializer()