【问题标题】:In grid view shortened String value在网格视图中缩短字符串值
【发布时间】:2022-01-02 16:28:53
【问题描述】:

在我的 Flutter 任务应用程序中,我的项目有一个网格视图,如果文本很长,它会缩短字符串值。全文视图的任何解决方案?

【问题讨论】:

    标签: flutter dart mobile


    【解决方案1】:

    你应该使用pub.dev中的auto_size_text

    AutoSizeText(
      'A really long String',
      style: TextStyle(fontSize: 12),
      minFontSize: 4,
      maxLines: 1,
      overflow: TextOverflow.ellipsis,
    )
    

    【讨论】:

      【解决方案2】:

      您可以用 FittedBox 包裹您的 Text Widget 并提供最大 width

      Text 小部件中将 ma​​xLines 设置为 1。

      SizedBox(
            height: size.height * 0.1,
            width: size.width * 0.28,
            child: FittedBox(
              child: Text(
                "$number ",
                maxLines: 1,
                
              ),
            ),
          )
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-11-11
        • 1970-01-01
        • 1970-01-01
        • 2011-04-28
        • 2019-10-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多