flutter - How to draw a horizontal line in flutter row widgets?
问题描述
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-
解决方案
试着把你包裹起来Column
,Expanded
这样就Divider
知道要占用多少空间。
Container(
color: Colors.white,
child: (Row(
children: <Widget>[
// ...
Expanded(
child: Column(
children: <Widget>[
Text("Book Name"),
Text("Author name"),
Divider(
color: Colors.black
)
],
),
)
],
)),
);
推荐阅读
- php - 通过 PHP 创建 MySQL 触发器
- ag-grid - AG Grid React 图表工具栏不显示图表工具栏
- google-cloud-firestore - 无法在 Firestore 在线模拟器中使用“FieldValue.serverTimestamp”
- powerbi - DAX 使用当前行上下文搜索同一列
- python - 注释 __init__ 获取类型的参数,在类变量中声明
- python - 一系列阻塞调用的并发未来轮询
- css - 有没有地方可以找到 CSS 文件来自定义 MkDocs 的 Material Theme?
- android - 自定义 Lint 规则以检查布局中的所有视图
- html - 输入字段的渐变颜色
- jenkins - Jenkins 主动选择参数插件中未列出 S3 存储桶