White Space
Use whitespace-{value} utilities to control how whitespace and line breaks
are handled inside text.
Normal
Section titled “Normal”Use the whitespace-normal utility to cause text to wrap normally within an
element. Newlines and spaces will be collapsed.
Style('whitespace-normal', child: Text('Hey everyone!\n\nIt\'s almost 2022 and we still don\'t know if there are aliens living among us, or do we? Maybe the person writing this is an alien.\n\nYou will never know.'))No Wrap
Section titled “No Wrap”Use the whitespace-nowrap utility to prevent text from wrapping within an
element. Newlines and spaces will be collapsed.
Style('whitespace-nowrap', child: Text('Hey everyone!\n\nIt\'s almost 2022 and we still don\'t know if there are aliens living among us, or do we? Maybe the person writing this is an alien.\n\nYou will never know.'))Use the whitespace-pre utility to preserve newlines and spaces within an
element. Text will not be wrapped.
Style('whitespace-pre', child: Text('Hey everyone!\n\nIt\'s almost 2022 and we still don\'t know if there are aliens living among us, or do we? Maybe the person writing this is an alien.\n\nYou will never know.'))Pre Line
Section titled “Pre Line”Use the whitespace-pre-line utility to preserve newlines but not spaces
within an element. Text will be wrapped normally.
Style('whitespace-pre-line', child: Text('Hey everyone!\n\nIt\'s almost 2022 and we still don\'t know if there are aliens living among us, or do we? Maybe the person writing this is an alien.\n\nYou will never know.'))Pre Wrap
Section titled “Pre Wrap”Use the whitespace-pre-wrap utility to preserve newlines and spaces within
an element. Text will be wrapped normally.
Style('whitespace-pre-wrap', child: Text('Hey everyone!\n\nIt\'s almost 2022 and we still don\'t know if there are aliens living among us, or do we? Maybe the person writing this is an alien.\n\nYou will never know.'))Break Spaces
Section titled “Break Spaces”Use the whitespace-break-spaces utility to preserve newlines and spaces
within an element. White space at the end of lines will not hang, but will
wrap to the next line.
Style('whitespace-break-spaces', child: Text('Hey everyone!\n\nIt\'s almost 2022 and we still don\'t know if there are aliens living among us, or do we? Maybe the person writing this is an alien.\n\nYou will never know.'))Class reference
Section titled “Class reference”| Class | Behavior |
|---|---|
whitespace-normal | Collapses whitespace runs to single spaces; wraps |
whitespace-nowrap | Collapses whitespace; no wrap |
whitespace-pre | Preserves whitespace + newlines; no wrap |
whitespace-pre-line | Collapses spaces; preserves newlines; wraps |
whitespace-pre-wrap | Preserves whitespace + newlines; wraps |
whitespace-break-spaces | Like pre-wrap; trailing spaces wrap |
Flutter’s Text widget does not natively collapse CSS whitespace, so the
library applies the equivalent string mutation in _applyTextStyle before the
text is laid out. The breakSpaces mode is treated as preWrap since Flutter
makes no distinction between trailing-space wrapping and normal wrapping.