如果存在borderRadius,则不会显示容器

时间:2019-08-01 04:04:58

标签: flutter

我正在尝试使用animationPosition小部件创建一个带有圆角的自定义滑动底部容器,但是每次我在容器中添加borderRadius时,该容器都不会显示

这是我一直在努力的代码


class ProductPage extends StatefulWidget {
  const ProductPage({Key key}) : super(key: key);

  @override
  _ProductPageState createState() => _ProductPageState();
}

class _ProductPageState extends State<ProductPage> {
  bool show = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.green,
      body: SafeArea(
        child: GestureDetector(
          onTap: () {
            FocusScope.of(context).unfocus();
            setState(() {
              show = !show;
            });
            print(show);
          },
          child: Container(
            color: Colors.white,
            child: Stack(
              children: <Widget>[
                new _ProductPageBody(),
                !show
                    ? Positioned.fill(
                        child: Container(
                        color: Colors.black.withOpacity(0.5),
                      ))
                    : Container(),
                AnimatedPositioned(
                    bottom: show ? -500 : 0,
                    duration: Duration(milliseconds: 500),
                    curve: Curves.easeIn,
                    child: Container(
                      height: 500,
                      width: double.maxFinite,
                      decoration: BoxDecoration(
                          color: Colors.black,
                          borderRadius:
                              BorderRadius.circular(10)),
                    )),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

1 个答案:

答案 0 :(得分:0)

尝试用ClipRRect替换内部容器

   AnimatedPositioned(
                    bottom: show ? -500 : 0,
                    duration: Duration(milliseconds: 500),
                    curve: Curves.easeIn,
                    child: ClipRRect(
                          borderRadius:
                              BorderRadius.circular(10),
child: AnyWidget
    ),
                    )),