小编Aka*_*vya的帖子

如何修复 Flutter 中水平列表视图中的裁剪阴影

当我在 ListView 中创建一个带有框阴影的容器(水平滚动)时,阴影看起来不错,但是,当我在 ListView 中添加多个容器时,它们的阴影(只是阴影,而不是容器)在顶部和底部被裁剪。

另请注意,整个 ListView 都包裹在父容器下。

我试图增加父容器的高度(整个 ListView 被包裹在其中),但它增加了子容器的高度,其阴影仍然被裁剪。

我还尝试为父容器提供填充,但是阴影仍然会被裁剪。

也许我需要将 ListView 包装在任何其他可以毫无问题地完成工作的小部件中。

Container(
  // padding: EdgeInsets.only(left: 30.0, right: 0.0),
  height: 140.0,
  child: ListView(
    scrollDirection: Axis.horizontal,
    children: <Widget>[
      SizedBox(
        width: 30.0,
      ),
      Container(
        //This is actual custom Card
        width: 340.0,
        height: 140.0,
        decoration: BoxDecoration(
          boxShadow: [
            BoxShadow(
              color: Colors.black12,
              offset: Offset.zero,
              blurRadius: 10.0,
              spreadRadius: 0.0,
            )
          ],
          color: Colors.white,
          borderRadius: BorderRadius.circular(10.0),
        ),
        child: Row(
          children: <Widget>[
            Container(
              padding: EdgeInsets.fromLTRB(
                  30.0, 20.0, 25.0, 20.0),
              child: Image.asset(
                  'assets/images/leather_boot.png'),
            ),
            Container( …
Run Code Online (Sandbox Code Playgroud)

dart flutter

9
推荐指数
2
解决办法
4604
查看次数

标签 统计

dart ×1

flutter ×1