简体   繁体   English

Flutter-Flutter 中是否可以将 RichText 类放在 Container 类中

[英]Flutter-Is it possible to put a RichText class within a Container class in flutter

So I am currently working on an app project and I have arrived at a point where I want to put two text lines within a row on top of each one and other.所以我目前正在处理一个应用程序项目,我已经到了一个点,我想将两个文本行放在一行中,并放在一个和另一个的顶部。 As an example it should like this app demo created with figma .作为一个例子,它应该喜欢这个用 figma 创建的应用程序演示 So far I have a row in which every element on the same altitude is contained within, but I am having a hard time being able to put 2 elements within a row on top of each other.到目前为止,我有一排相同高度的每个元素都包含在其中,但我很难将 2 个元素放在一行中。 I have found out this class called Stack but I am having a hard time implementing it.我发现了这个叫做 Stack 的类,但我很难实现它。 Within my Stack class I have a RichText Class.在我的 Stack 类中,我有一个 RichText 类。 From the flutter api, what I understand is that you have to use containers (to be able to define the positions).从flutter api,我的理解是您必须使用容器(才能定义位置)。 So I wonder if I should switch to container classes right after the Stack class and then within each Container class, I put a RichText?所以我想知道我是否应该在 Stack 类之后立即切换到容器类,然后在每个 Container 类中,我放置一个 RichText? If I could have some advice on this, or simply on how to create something like in the picture it would be great.如果我可以就此提出一些建议,或者只是关于如何创建图片中的内容,那就太好了。 Thanks in advance.提前致谢。

Added a demo of what you are trying to achieve:添加了您要实现的目标的演示:

        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            // row containing the avatar, name, date and icons (likes and comments)
            Row(
              children: [
                // circle avatart
                CircleAvatar(
                  backgroundColor: Colors.blue,
                  radius: 25,
                ),
                // spacing
                SizedBox(
                  width: 10,
                ),

                // the name of poster and date in a column
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      'Claire',
                    ),
                    Text(
                      'July 03 at 13:08PM',
                    ),
                  ],
                ),
                // spacer
                Spacer(),

                // likes icon
                Icon(Icons.favorite_border),
                Text(
                  '32',
                ),

                // spacing
                SizedBox(
                  width: 10,
                ),

                // comments icon
                Icon(
                  Icons.comment,
                ),
                Text(
                  '32',
                ),
              ],
            ),
            // spacing
            SizedBox(
              height: 10,
            ),
            // title text
            Text(
              'Dorm recommendation',
            ),

            // decription
            Text(
              'Any recommendations on dorm application? Does anyone know how\'s the facility at Talent Apartment? Are there teamrooms and gym in TA? Also, updates on the location of washers and dryers?',
              maxLines: 3,
              overflow: TextOverflow.ellipsis,
            ),
          ],
        ),

RESULT:结果:

结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM