我想在 Flutter 中实现一个行 ListView ,或多或少是这样的。
我找到了一个示例代码,并将其修改为:
body: Container(
child: ListView(
children: <Widget>[
Container(
padding: EdgeInsets.all(10),
child: Row(
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.all(15.0),
height: 100.0,
color: Colors.blue[200],
child: Row (
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("Artikel 1", style: TextStyle(color: Colors.white, fontSize: 15.0)),
Text("Ini adalah contoh artikel pada listview dengan versi custom", style: TextStyle(color: Colors.white),)
],
),
),
)
],
),
),
可以找到完整代码here .
结果如下:
如何修复“右侧溢出 61 像素”错误?
最佳答案
您的问题是 CTRL+C 和 CTRL+V。
第一个容器有一行,应该有一列。
child: Row (
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("Artikel 1", style: TextStyle(color: Colors.white, fontSize: 15.0)),
Text("Ini adalah contoh artikel pada listview dengan versi custom", style: TextStyle(color: Colors.white),)
],
),
应该是:
child: Column (
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("Artikel 1", style: TextStyle(color: Colors.white, fontSize: 15.0)),
Text("Ini adalah contoh artikel pada listview dengan versi custom", style: TextStyle(color: Colors.white),)
],
),
关于android - flutter 问题 : overflowed by 61 pixels on the right?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56933671/