flutter 文字过长超出范围,Flutter-列内扩展小部件内的文本溢出

在Flutter中,当Column内的Text组件文字过长时,如何避免超出固定高度的容器。问题在于文本溢出了其父容器,尽管设置了TextOverflow.ellipsis和maxLines属性。解决方案是将Column包裹在Flexible组件中,而不是Expanded组件。
摘要由CSDN通过智能技术生成

What I want to achieve is to have a text widget inside a Column of fixed height. When the text is long I want the overflow property which is set to TextOverflow.ellipsis to kick in. The Text widget has its maxLines property set to a high value to allow it to wrap down. But there are other widgets in the column too, both before and after the text widget. The text widget is in an Expanded widget so that it takes up as much room in the column. Full code is pasted below.

The problem with this setup is that the text is overflowing its container parent. I have a border decoration on the container that shows this happening. Why is this happening and how do I fix it.

import 'package:flutter/material.dart';

void main() {

runApp(App());

}

class App extends StatelessWidget {

@override

Widget build(BuildContext context)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值