如何更改ListView中元素的宽度?

Abb*_*ari 5 dart flutter

我有一个包含一些项目的 ListView,但我的问题是 ListView 内的项目将扩展到整个屏幕宽度,我尝试使用 SizedBox 和 Container 但它对我不起作用。这是我的代码:

  body: ListView.builder(
    itemCount: 10,
    itemBuilder: (ctx, index) {
      return SizedBox(
        width: 10,
        height: 10,
        child: Card(
          color: btnColor,
          child: Text(
            "Helo",
            // loremIpsum,
            style: TextStyle(color: Colors.black.withOpacity(0.6)),
          ),
        ),
      );
    },
  ),
Run Code Online (Sandbox Code Playgroud)

Abb*_*ari 3

我通过此链接解决了我的问题:

body: ListView.builder(
        itemCount: 10,
        itemBuilder: (ctx, index) {
          return Row(
            children: [
              Container(height: 50, width: 50, color: Colors.black),
            ],
          );
        },
      ),
Run Code Online (Sandbox Code Playgroud)

只需在 ListView 中使用 Row