Flutter 文本在句子开头溢出
Flutter text overflow at beginning of sentence
我需要在句子的开头有溢出 属性 的文本,所以不用
A very looooooooooong senten...
我希望省略号的结果是
...ery looooooooooong sentence.
这能以某种方式设置吗?
根据这个 github issue,目前没有办法用 Material 文本小部件的溢出 属性。
但是您可以使用 extended_text 包中的 ExtendedText()
小部件。
@override
Widget build(BuildContext context) {
return const Scaffold(
body: SafeArea(
child: ExtendedText(
'A very looooooooooong sentence.',
maxLines: 1,
overflowWidget: TextOverflowWidget(
position: TextOverflowPosition.start,
child: Text(
"...",
style: TextStyle(fontSize: 23),
),
),
style: TextStyle(fontSize: 27),
),
),
);
}
我需要在句子的开头有溢出 属性 的文本,所以不用
A very looooooooooong senten...
我希望省略号的结果是
...ery looooooooooong sentence.
这能以某种方式设置吗?
根据这个 github issue,目前没有办法用 Material 文本小部件的溢出 属性。
但是您可以使用 extended_text 包中的 ExtendedText()
小部件。
@override
Widget build(BuildContext context) {
return const Scaffold(
body: SafeArea(
child: ExtendedText(
'A very looooooooooong sentence.',
maxLines: 1,
overflowWidget: TextOverflowWidget(
position: TextOverflowPosition.start,
child: Text(
"...",
style: TextStyle(fontSize: 23),
),
),
style: TextStyle(fontSize: 27),
),
),
);
}