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

Textのはみ出した文字を隠すには、引数「overflow」を使います。
具体的には、Textの引数「overflow」に、次の3つのいずれかを指定します。
- TextOverflow.clip : はみ出した文字は隠す
- TextOverflow.ellipse : はみ出した文字を「・・・」で隠す
- TextOverflow.fade : はみ出した文字をフェードで隠す
Text(
'テキスト',
overflow: TextOverflow.〇〇,
),
使用例

@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),
),
),
),
),
);
}
コメント