首页 > 解决方案 > 如何在颤振中将欢迎文本放在用户名之前?

问题描述

我正在创建一个简单的颤振应用程序。

我有一个关于如何在从 api 调用值之前放置文本的问题

这是我想要实现的输出

Hello, $username
Tittle : $adsTitle

****
Hello, Jack
Tittle : Make A wish

 Profile profile = snapshot.data[index];
                      return Card(
                          child: Padding(
                            padding: const EdgeInsets.all(8.0),
                            child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget> [
                             Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: Center(child:user == null ? Text('') : Text((user), style: 
                                TextStyle(fontSize: 30) )),
                                Center(
                                child: Text('${profile.adsTitle}', style: TextStyle(fontSize: 25, color: 
                                mainColor),
                                ),
                              ),
                              ),
                          ],
                         ),
                        ),
                      );

怎么把文字Hello放在child: Center(child:user == null ? Text('') : Text((user), style: TextStyle(fontSize: 30))),

并且Tittle Center(child: Text('${profile.adsTitle}', style: TextStyle(fontSize: 25, color: mainColor),),),

标签: flutter

解决方案


像这样

Text("Hello $user");

推荐阅读