sách gpt4 ăn đã đi

Flutter - 在溢出时换行,例如插入省略号或淡入淡出

In lại Tác giả: IT Lão Cao 更新时间:2023-10-28 13:48:21 34 4
mua khóa gpt4 giày nike

我正在尝试创建一个中心文本具有最大大小的行,如果文本内容太大,它适合大小。

我插入 TextOverflow.ellipsis 属性以缩短文本并插入三点 ... 但它不起作用。

main.dart

nhập 'gói:flutter/material.dart';

hàm main() {
runApp(MyApp mới());
}

lớp MyApp mở rộng StatelessWidget {
@ghi đè
Xây dựng tiện ích (BuildContext context) {
trả về MaterialApp mới(
home: new HomePage(),
);
}
}

class HomePage extends StatelessWidget {
@ghi đè
Widget build(BuildContext context) => new Scaffold(
appBar: AppBar mới(
backgroundColor: new Color(0xFF26C6DA),
),
body: new ListView (
trẻ em: [
new Card(
child: new Container(
padding: new EdgeInsets.symmetric(horizontal: 16.0, vertical: 18.0),
child: new Row(
trẻ em: [
Container mới(
padding: new EdgeInsets.only(right: 24.0),
child: new CircleAvatar(
backgroundColor: new Color(0xFFF5F5F5),
radius: 16.0,
)
),
Container mới(
padding: new EdgeInsets.only(right: 13.0),
child: new Text(
'Text lar...',
overflow: TextOverflow.ellipsis,
style: new TextStyle(
fontSize: 13.0,
fontFamily: 'Roboto',
color: new Color(0xFF212121),
fontWeight: FontWeight.bold,
),
),
),
Container mới(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.end,
trẻ em: [
new Row(
trẻ em: [
new Text(
'Bill ',
style: new TextStyle(
fontSize: 12.0,
fontFamily: 'Roboto',
color: new Color(0xFF9E9E9E)
),
),
new Text(
'\$ -999.999.999,95',
style: new TextStyle(
fontSize: 14.0,
fontFamily: 'Roboto',
color: new Color(0xFF212121)
),
),
],
),
new Row(
trẻ em: [
new Text(
'Limit ',
style: new TextStyle(
fontSize: 12.0,
fontFamily: 'Roboto',
color: new Color(0xFF9E9E9E)
),
),
new Text(
'R\$ 900.000.000,95',
style: new TextStyle(
fontSize: 14.0,
fontFamily: 'Roboto',
color: new Color(0xFF9E9E9E)
),
),
],
),
]
)
)
],
),
)
),
]
)
);
}

kết quả:

nhập mô tả hình ảnh ở đây

预期:

nhập mô tả hình ảnh ở đây

câu trả lời hay nhất

您应该将您的 Container 包装在 Flexible 中让您的 Hàng ngang Biết Container 比其固有宽度窄是可以的。 Expanded也可以。

ảnh chụp màn hình

Flexible(
child: new Container(
padding: new EdgeInsets.only(right: 13.0),
child: new Text(
'Text largeeeeeeeeeeeeeeeeeeeeeee',
overflow: TextOverflow.ellipsis,
style: new TextStyle(
fontSize: 13.0,
fontFamily: 'Roboto',
color: new Color(0xFF212121),
fontWeight: FontWeight.bold,
),
),
),
),

关于Flutter - 在溢出时换行,例如插入省略号或淡入淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44579918/

34 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress