duatree
duatree

Reputation: 413

How do I put welcome text before username in flutter?

I'm creating a simple flutter application.

I have a problem on how do I put text before the value got called form the api

this is the output that I want to achieve

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

How do I put text Hello at the child: Center(child:user == null ? Text('') : Text((user), style: TextStyle(fontSize: 30))),

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

Upvotes: 0

Views: 472

Answers (2)

Hemal Moradiya
Hemal Moradiya

Reputation: 2097

You can use string interpolation

e.g.

Text("Hello $user")      

or

Text('Title ${profile.adsTitle}')

You can also use RichText widget for that.

Upvotes: 1

Ardeshir ojan
Ardeshir ojan

Reputation: 2419

Like this

Text("Hello $user");

Upvotes: 1

Related Questions