SoftHyphenText

This widget can be used like the text widget but takes care of soft hyphens inside strings and wraps the text accordingly.

Features

  • Handles soft hyphens (U+00AD) in text
  • Automatically adds visible hyphens when text wraps at a soft hyphen position
  • Preserves original text when no wrapping occurs
Screenshot of SoftHyphenText in action

Getting started

Add the package to your pubspec.yaml:

dependencies:
  soft_hyphen_text: ^0.0.1

Usage

Simply use the SoftHyphenText widget instead of the standard Text widget:

SoftHyphenText(text: 'Hello­world')

The soft hyphen character (U+00AD) is invisible but indicates potential hyphenation points. When the text wraps at these points, a visible hyphen will be displayed.

Example with different container widths

Column(
  children: [
    Container(
      width: 80,
      child: SoftHyphenText(text: 'TextWithSoftHyphenCharacter'),
    ),
  ],
)

Additional information

  • All standard Text widget properties like style, textAlign, etc. are supported.

Libraries

soft_hyphen_text