どうも、ちょげ(@chogetarou)です。
Textのはみ出した文字の表示を設定する方法を紹介します。
方法

Textのはみ出した文字の表示を設定するには、引数「overflow」を使います。
具体的には、Textの引数「overflow」に表示方法を指定します。
表示方法の指定には、TextOverflowを使います。
Text(
'テキスト',
overflow: TextOverflow.〇〇, //TextOverflowの値を指定
),
引数「overflow」に指定した値が、Textのはみ出した文字の表示方法に設定されます。
使用例

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: Container(
width: 100,
height: 30,
child: Text(
'Hello,Flutter',
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 24),
),
),
),
),
);
}
コメント