簡體   English   中英

Flutter-Flutter 中是否可以將 RichText 類放在 Container 類中

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

所以我目前正在處理一個應用程序項目,我已經到了一個點,我想將兩個文本行放在一行中,並放在一個和另一個的頂部。 作為一個例子,它應該喜歡這個用 figma 創建的應用程序演示 到目前為止,我有一排相同高度的每個元素都包含在其中,但我很難將 2 個元素放在一行中。 我發現了這個叫做 Stack 的類,但我很難實現它。 在我的 Stack 類中,我有一個 RichText 類。 從flutter api,我的理解是您必須使用容器(才能定義位置)。 所以我想知道我是否應該在 Stack 類之后立即切換到容器類,然后在每個 Container 類中,我放置一個 RichText? 如果我可以就此提出一些建議,或者只是關於如何創建圖片中的內容,那就太好了。 提前致謝。

添加了您要實現的目標的演示:

        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,
            ),
          ],
        ),

結果:

結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM