widget - 将文本小部件相互环绕

标签 widget flutter instagram

如何在flutter中实现instagram like comment ROW?

与:

              return Padding(
                padding: const EdgeInsets.all(8.0),
                child: new Column(
                  children: <Widget>[
                    Row(
                      children: <Widget>[
                        new Icon(MdiIcons.accountCircle,
                            size: 40.0, color: Colors.black),
                        new SizedBox(width: 5.0),
                        new Text(
                          data[index].username,
                          style: new TextStyle(
                              fontSize: 15.0, fontWeight: FontWeight.w500),
                        ),
                        new SizedBox(
                          width: 5.0,
                        ),
                        new Flexible(
                            child: new Text(
                          "A really really really really realky long comment ${data[index].comment}"
                          style: new TextStyle(
                              fontSize: 15.0, fontWeight: FontWeight.w300),
                        )),
                      ],
                    ),
                    new Row(
                      children: <Widget>[
                        new SizedBox(
                          width: 45.0,
                        ),
                        new Text(
                          "1h ago",
                          style: new TextStyle(color: Colors.grey),
                        )
                      ],
                    ),
                    new Divider(
                      height: 2.0,
                    )
                  ],
                ),
              );

我实现了这个:

enter image description here

我要实现:

enter image description here

基本上,如果我们打破 Instagram 中每一行的 UI,

它是一个 userAvatar,后跟用户名,然后是评论,在下一行继续BELOW(强调在下面)用户名然后在下一行是时间和喜欢

最佳答案

您可以使用称为 RichText 的东西来获得这种效果

 new RichText(
      text: new TextSpan(
        children: <TextSpan>[
          new TextSpan(
            text: 'You don\'t have the votes.',
            style: new TextStyle(color: Colors.black,fontSize: 20.0),
          ),
          new TextSpan(
            text: 'You don\'t have the votes!',
            style: new TextStyle(color: Colors.red,fontSize: 30.0,),
          ),
        ],
      ),
    )

希望对你有帮助!

关于widget - 将文本小部件相互环绕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51811717/

相关文章:

ios - 我的小部件似乎没有安装到我的 Xcode 12 模拟器上

c++ - 从整数数组在 gtkmm 中显示图像

Flutter 头文件替代方案

node.js - 在本地测试 Instagram Basic API

android - 更改 Android Widget 中的 TextView 文本

python - 模式匹配 Tkinter 子小部件 (winfo_children) 以确定类型

android - 新的pubspec Flutter插件声明导致MissingPluginException

dart - Flutter : Custom UI for Scan QR Reader. 请让我知道任何插件,以便我可以在扫描屏幕底部制作菜单

instagram - Instagram无法访问回调URL

C# Instasharp 设置帮助(Instagram API)