这是一个代码:
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: Home()));
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
width: 200,
color: Colors.green[200],
child: Text(
'https://someurl.com/4792479008289298462374623746723457',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
softWrap 在这种情况下没有帮助
遵循 Github 问题:带有省略号的文本溢出设计怪异和丑陋
这是它的快速修复:
- 在
TextOverflow.ellipsis使用正则表达式模式\u2026,你可以申请一个正则表达式[\u{200B}]上Text data
代码 :
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
width: 200,
color: Colors.green[200],
child: Text(
'https://someurl.com/479247900828929846'.replaceAll("", "\u{200B}"),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
- 使用 flutter 包,它使您能够执行此Assorted Layout Widgets
| 归档时间: |
|
| 查看次数: |
360 次 |
| 最近记录: |