To make text underlined in Flutter using the Text widget, you can use the TextStyle property with the decoration parameter set to TextDecoration.underline. Here’s a simple example:
Text(
'Underlined Text',
style: TextStyle(
decoration: TextDecoration.underline,
),
)
Additional Options
Customize the underline style: You can further customize the underline using properties like decorationColor, decorationStyle, and decorationThickness:
Text(
'Custom Underlined Text',
style: TextStyle(
decoration: TextDecoration.underline,
decorationColor: Colors.blue, // Color of the underline
decorationStyle: TextDecorationStyle.dashed, // Style: solid, dashed, dotted, double, wavy
decorationThickness: 2.0, // Thickness of the underline
fontSize: 20, // Optional: other text styling
),
)
Available decorationStyle options:
- TextDecorationStyle.solid (default)
- TextDecorationStyle.dashed
- TextDecorationStyle.dotted
- TextDecorationStyle.double
- TextDecorationStyle.wavy
This approach ensures the text is underlined with the desired style.
