firebase - 如何在多行上显示我的文本?

标签 firebase flutter dart google-cloud-firestore

我正在尝试弄清楚如何在多行上显示我的文本。这是我的代码:

    title: Row(
                                      children: [
                                        Text(
                                            _snapshot.data['username'],
                                          style: TextStyle(
                                              color: Colors.black,
                                              fontSize: 20,
                                              fontWeight: FontWeight.w700),
                                        ),
                                        SizedBox(width: 5.0),
                                        Text(
                                          "${comment.data()['comment']}",
                                          style: TextStyle(
                                              color: Colors.black,
                                              fontSize: 20,
                                              fontWeight: FontWeight.w500),
                                        )
                                      ],
                                    ),

但是当文本太长时我会得到这个错误:

enter image description here

当我用扩展包住第二个文本时,它看起来像那样

我想要这样的东西

enter image description here

最佳答案

我想你可以尝试使用 RichText,看这段代码:

   RichText(
      text: TextSpan(
        text: 'Title ', // _snapshot.data['username']
        style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
        children: <TextSpan>[
          TextSpan(//"${comment.data()['comment']}"
            text: 'this is a very long text text text'
                'text text text text text text text text text text'
                'text text text text text text text text text',
            style: TextStyle(
              fontWeight: FontWeight.normal,
            ),
          )
        ],
      ),
    ),

关于firebase - 如何在多行上显示我的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67426534/

相关文章:

FirebaseUser isEmailVerified 即使在验证电子邮件后也始终返回 false

flutter - 如何在 flutter 中解析网络套接字响应(JSON)

dart - Flutter 中的多个目标和多个构建配置

flutter - 如果指定了home属性,则路由表不能包含/的条目

firebase - 在 flutter webapp 中通过 Adyen 付款

javascript - Firebase 安全规则 : restrict write only to this uid,,几个字段除外

javascript - 使用 AngularFire 创建用户并调用工厂来显示通知

dart - Dart Web组件何时需要删除已删除的生命周期方法?

java - 当自定义索引不是 Firestore 中的选项时该怎么办

javascript - 在 Firebase 中制作用于更新数据的 Web 表单