Search code examples
flutterdartrowpadding

How to add space in one row (Flutter)?


I'm a beginner. I have one row and 2 buttons in it. I want to add space between them, for example padding, margin, container or something. I tried a lot of solutions from other questions, but nothing works for me.

My code:

   Row(
      children: <Widget>[
        Expanded(
            child: ElevatedButton(
          onPressed: () {},
          child: Text("Scan"),
        )),
        Expanded(
            child: ElevatedButton(
          onPressed: () {},
          child: Text("Manually"),
        )),
      ],
    );

Solution

  • You can add padding around the button on which you want to give space

    Row(
                children: <Widget>[
                  Expanded(
                      child: ElevatedButton(
                    onPressed: () {},
                    child: Text("Scan"),
                  )),
                  SizedBox(
                    width: 100,
                  ),
                  Expanded(
                      child: Padding(
                        padding: const EdgeInsets.only(left:8.0),
                        child: ElevatedButton(
                    onPressed: () {},
                    child: Text("Manually"),
                  ),
                      )),
                ],
              ),