抖动问题:右侧溢出了61个像素?

时间:2019-07-08 11:11:11

标签: android flutter

我想像这样或多或少地在Flutter中实现行的ListView。 enter image description here

我找到了一个示例代码,并将其修改为:

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

结果如下:

enter image description here

如何解决“右侧溢出61个像素”错误?

1 个答案:

答案 0 :(得分:1)

您的问题是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),)
                        ],
                      ),

相关问题