Docs
Guides
Directives

Directives

Directives in Mix are specialized attributes that define transformations to be applied to widgets during the build process. They are particularly useful for dynamically modifying widget properties based on specific conditions or parameters.

Example: Text Directives

A prime example is the TextDirective, which allows for text case transformations in StyledText widgets.

const TextMix(
  'Hello World',
  style:  Style(
    upperCase(),
  ),
),

n this example, the text "Hello World" is transformed to "HELLO WORLD" using the upperCase() directive.

Directives catalog

Mix provides a range of directives, which allow for a variety of transformations to be applied to widgets. The following is a list of all available directives:

Text Directives

  • capitalize(): Capitalizes the first letter of each word.
  • upperCase(): Converts all characters to uppercase.
  • lowerCase(): Converts all characters to lowercase.
  • titleCase(): Transforms the first letter of each word in a sentence to uppercase.
  • sentenceCase(): Transforms the first letter of the first word in a sentence to uppercase.