Search code examples
androidflutterseparatordivider

How to add a Vertical Divider between Widget on Column in Flutter?


Good day.

I've surfed on this website about how to add a Vertical Divider between Widget on Column in Flutter? but I got nothing.

here what I want enter image description here

I already make the horizontal divider. but when I try to make a vertical divider that separating between 2 objects (text | image), I got nothing.

here are the code:

Row(children: <Widget>[
                Expanded(
                  child: new Container(
                      margin: const EdgeInsets.only(left: 10.0, right: 20.0),
                      child: Divider(
                        color: Colors.black,
                        height: 36,
                      )),
                ),
                Text("OR"),
                Expanded(
                  child: new Container(
                      margin: const EdgeInsets.only(left: 20.0, right: 10.0),
                      child: Divider(
                        color: Colors.black,
                        height: 36,
                      )),
                ),
              ]),

code above is for horizontal

Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            Row(
              children: <Widget>[
                Image.asset('images/makanan.png', width: 30,),
                Text('Diskon 20%', style: TextStyle(fontSize: 5, color: Colors.green),)
              ],
            ),
            VerticalDivider(
              color: Colors.red,
              width: 20,
            ),
            Row(
              children: <Widget>[
                Image.asset('images/makanan.png', width: 30,),
                Text('Diskon 20%', style: TextStyle(fontSize: 5, color: Colors.green),)
              ],
            ),
          ],
        ),

code above I make for Vertical Divider. but failed.

Need your help, Thank you.


Solution

  • Try to replace

    VerticalDivider(color: Colors.red, width: 20)
    

    with

    Container(height: 80, child: VerticalDivider(color: Colors.red))