Flutter - Text Overline
The Text widget displays a string of text with a single style in a flutter
app. But depending on the layout constraints the string might break across
multiple lines or might all be displayed on the same line. The style argument
is optional in a Text instance. When the style argument is omitted, the text
will use the style from the closest enclosing DefaultTextStyle. By default,
the Text is not selectable. But flutter developers can make a Text selectable
by wrapping a subtree with a SelectionArea widget.
The following flutter application development tutorial will demonstrate how we can overline the Text widget’s text. In this example code, we will use the TextStyle class decoration property to decorate the Text by putting an overline.
The TextStyle class represents an immutable style describing how to format and paint text. The TextStyle class decoration property is used to apply decorations to paint near the text such as an overline. The flutter app developer can apply multiple decorations with TextDecoration.combine.
The TextDecoration class represents a linear decoration to draw near the text. The TextDecoration class’s overline const draws a line above each line of text.
So finally, the flutter app developers can show an overline on a Text by using the TextStyle class’s decoration property. But the developers also have to set the decoration property value to the overline constant as TextDecoration.overline.
The following flutter application development tutorial will demonstrate how we can overline the Text widget’s text. In this example code, we will use the TextStyle class decoration property to decorate the Text by putting an overline.
The TextStyle class represents an immutable style describing how to format and paint text. The TextStyle class decoration property is used to apply decorations to paint near the text such as an overline. The flutter app developer can apply multiple decorations with TextDecoration.combine.
The TextDecoration class represents a linear decoration to draw near the text. The TextDecoration class’s overline const draws a line above each line of text.
So finally, the flutter app developers can show an overline on a Text by using the TextStyle class’s decoration property. But the developers also have to set the decoration property value to the overline constant as TextDecoration.overline.
main.dart
import 'package:flutter/material.dart';
void main(){
runApp(
MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("Flutter - Text Overline")
),
body: const Center(
child: Text(
"Lorem Ipsum is simply dummy text of the printing"
" and typesetting industry.",
style: TextStyle(
fontSize: 24,
decoration: TextDecoration.overline,
decorationStyle: TextDecorationStyle.solid,
decorationColor: Colors.blueGrey,
decorationThickness: 1.5
),
textAlign: TextAlign.center,
)
),
),
)
);
}