In my flutter project, I have initialized a Row. Inside that, I created some Texts in a column and after that, I want to add a line but it is not showing anything. I have used Expanded for that reason and followed the given solutions-
Horizontal divider with text in the middle in Flutter?
But none of them worked either.
Here's the image of my code output-
Here's my code-
Container( color:Colors.white, child: ( Row( children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: Image( height: 100, width: 100, image: NetworkImage("https://www.gstatic.com/webp/gallery/1.jpg"), ), ), Column( children: <Widget>[ Text("Book Name"), Text("Author name"), Divider( color: Colors.black, ) ], ) ], ) ), ),
So, I need a line below the two texts and show it like the below picture-
If you have a list of widgets, you may need to add a separator between the widgets. In Flutter, there are two widgets suitable for that purpose: Divider and VerticalDivider . Divider is used to create a horizontal line divider, while VerticalDivider is used to create a vertical line divider.
“horizontal divider in flutter” Code Answer'sindent: 20, // empty space to the leading edge of divider. endIndent: 20, // empty space to the trailing edge of the divider. color: Colors. black, // The color to use when painting the line.
If we want to make a scrollable list of row widgets, we need to use the ListView widget. We can control how a row widget aligns its children based on our choice using the property crossAxisAlignment and mainAxisAlignment. The row's cross-axis will run vertically, and the main axis will run horizontally.
Try wrapping you Column
in an Expanded
so the Divider
knows how much space to occupy.
Container( color: Colors.white, child: (Row( children: <Widget>[ // ... Expanded( child: Column( children: <Widget>[ Text("Book Name"), Text("Author name"), Divider( color: Colors.black ) ], ), ) ], )), );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With