2

I use flutter to do RaisedButton with icon and the the icon and text I want change position to left. How to do it? This is my code for button.

I want do it like in the image:

enter image description here

Card(
                  child: SizedBox(
                    width: double.infinity,
                    height: 60,
                    child: RaisedButton.icon(
                      icon: Icon(Icons.home,
                          size: 40, color: Theme.of(context).primaryColor),
                      color: Colors.white,
                      textColor: Theme.of(context).primaryColor,
                      label: const Text('Electrical and Wiring',
                          style: TextStyle(
                              fontWeight: FontWeight.normal, fontSize: 15)),
                      onPressed: () => {},
                    ),
                  ),
                ),

4 Answers 4

9

What you can do you can use Directionality widget in flutter with TextButton.icon(). Here is the Code.

 Directionality(
            textDirection: TextDirection.rtl,
            child: TextButton.icon(
              onPressed: null,
              icon: Icon(
                CupertinoIcons.ellipsis_circle_fill,
                color: Colors.green,
              ),
              label: Text(
                "Business Name",
                style: Theme.of(context).textTheme.subtitle1,
              ),
            ),
          ),

And here is the View.

enter image description here

3

in the Raised Button Widget you can put a Row() or a Column() as the child, so it can be easily done like this,

RaisedButton(
    child: Row(
      children: <Widget>[
        Icon(Icons.call),
        Text('Your Text'),
      ],
    ),
    onPressed: (){
    //Actions
  }),
1

You can achieve that using RaisedButton.icon() widget..

You can get more information from documentation.

Here's a minimal example for you..

RaisedButton.icon(onPressed: null, icon: null, label: null);
0

Try this

GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: () {},
        child: Card(
          child: SizedBox(
              width: double.infinity,
              height: 60,
              child: Row(
                children: [
                  Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 8),
                    child: Icon(Icons.home,
                        size: 40, color: Theme.of(context).primaryColor),
                  ),
                  Text('Electrical and Wiring',
                      style: TextStyle(
                          fontWeight: FontWeight.normal, fontSize: 15)),
                ],
              )),
        ),
      ),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.