kiroma
kiroma

Reputation: 23

How to add iconbutton at the end of the text in Flutter?

How can I add the iconbutton at the end of the text like this ?

Pic

I use Row widget but the iconbutton is not in the right place, it is not at the end of the text

Pic

This is my code:

Row(
        children: [
          Expanded(
            child: Text(
              'All about marketing, lead generation, content marketing and growth hacks',
              style: const TextStyle(
                  fontSize: 12.0, fontWeight: FontWeight.w500),
            ),
          ),
          IconButton(
            icon: Icon(Icons.info),
            iconSize: 12.0,
            color: Palette.appbar,
            onPressed: () {},
          ),
        ],
      ),

Upvotes: 2

Views: 884

Answers (1)

Taur
Taur

Reputation: 564

Use RichText with TextSpan and WidgetSpan.

WidgetSpan allow to add your own widget as a part of text.

like this :

    RichText(
      text: TextSpan(
        children: <TextSpan>[
          TextSpan(text: _text, style: _style),
          WidgetSpan(
            child:  _child
          )
        ],
      ),

Upvotes: 4

Related Questions