如何在行中显示2个文本,text1可以是省略号,但text2应该在flutter中显示全长

问题描述 投票:0回答:1

行[图像,文本1,文本2,图像]

这里Text1是名称,Text2是ID,Image固定大小25,需要显示在行尾。

flutter text row expand flexibility
1个回答
0
投票
Like This :

Row(
  children: [
    // text1 will take available space and be truncated with ellipsis
    Expanded(
      child: Text(
        'This is a long text1 that will be truncated with ellipsis',
        overflow: TextOverflow.ellipsis, // Adds ellipsis if overflow occurs
        style: TextStyle(fontSize: 16),
      ),
    ),
    SizedBox(width: 10), // Add some spacing between the texts
    // text2 will take only the space it needs and display fully
    Text(
      'Full text2',
      style: TextStyle(fontSize: 16),
    ),
  ],
)
© www.soinside.com 2019 - 2024. All rights reserved.