📜  防止文本溢出颤动 - Dart 代码示例

📅  最后修改于: 2022-03-11 14:48:02.851000             🧑  作者: Mango

代码示例3
// To me wrapping the overflowing component in a Flexible did the trick
Row(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Icon(Icons.arrow_back),
        Container(
          width: 5,
        ),
        Flexible( // to fix overflowing texts
          child: RichText(
            maxLines: 2,
            overflow: TextOverflow.ellipsis,
            text: TextSpan(
                text: 'A long text',
                style: TextStyle(fontWeight: FontWeight.bold),
                children: [
                  TextSpan(
                      text: '\n' + 'A very long text you would not believe it is so long',
                      style: TextStyle(fontWeight: FontWeight.bold))
                ]),
          ),
        ),
      ],
    )