如何在颤动的列表视图中设置卡片的宽度?

Cre*_*tor 2 listview resize dart flutter card

我有一个卡片列表,但是当我更改卡片的宽度时,它仍然采用与父容器相同的宽度。我尝试过用大小合适的盒子或容器包装列表视图、卡片甚至滚动视图,但没有任何效果。

  Container(
              height: MediaQuery.of(context).size.height * 0.6,
              width: MediaQuery.of(context).size.width * 0.8,
              decoration: BoxDecoration(
                color: kWhiteColor,
                borderRadius: BorderRadius.all(
                    Radius.circular(MediaQuery.of(context).size.height * 0.02)),
              ),
              child: Padding(
                padding:
                    EdgeInsets.all(MediaQuery.of(context).size.height * 0.015),
                child: SingleChildScrollView(
                  scrollDirection: Axis.vertical,
                  child: ListView.builder(
                    physics: const NeverScrollableScrollPhysics(),
                    shrinkWrap: true,
                    itemCount: 10,
                    itemBuilder: (BuildContext context, int index) {
                      return SizedBox(
                        width: MediaQuery.of(context).size.width*0.001,
                        height: MediaQuery.of(context).size.height*0.3,
                        child: Card(
                          color: Colors.black,
                        ),
                      );
                    },
                  ),
                ),
              ),
            ),
Run Code Online (Sandbox Code Playgroud)

我面临的问题

白卡后面是父容器,或者我们可以说是最外层的容器。

Er1*_*Er1 11

将您的孩子包裹在一个Align小部件中

return Align(
  alignment: Alignment.centerRight, //or choose another Alignment
  child: SizedBox(
    width: MediaQuery.of(context).size.width*0.001, //you sure it should be 0.001?
    height: MediaQuery.of(context).size.height*0.3,
    child: Card(
      color: Colors.black,
    ),
  ),
);
Run Code Online (Sandbox Code Playgroud)