flutter - 如何在Flutter中实现模糊背景Bottom Modal Sheet?

我正在做一个项目,为此我想要一个图像背景模糊的底页。为此,我实现了这段工作正常但有一个问题的代码。


  Widget build(BuildContext context) {
    return Container(
      height: MediaQuery.of(context).size.height * 0.33,
      child: Stack(
        overflow: Overflow.visible,
        fit: StackFit.expand,
        children: [
          Container(
            height: MediaQuery.of(context).size.height * 0.25,
            decoration: new BoxDecoration(
                image: new DecorationImage(
              image: new AssetImage("assets/images/bookshelf.jpg"),
              fit: BoxFit.cover,
            )),
          ),
          Positioned(
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height * 0.25,
            child: BackdropFilter(
              filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
              child: Container(color: Colors.white.withOpacity(0)),
            ),
          ),
        ],
      ),
    );
  }

输出是这样的: 它模糊了整个屏幕,但我只想在模态表中模糊。我的问题是什么?我是新手,所以对它了解不多。请帮我解决这个问题。

最佳答案

这是你的解决方案,

 showModalBottomSheet(
              context: context,
              clipBehavior: Clip.antiAlias,
              builder: (context){
                return Container(
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: AssetImage("assets/images/bookshelf.jpg"),
                    ),
                  ),
                  child: BackdropFilter(
                    filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
                    child: Center(
                      child: Text('welcome'),
                    ),
                  ),
                );
              }
          );

https://stackoverflow.com/questions/63722321/

相关文章:

python - 使用最佳学习率导致随机猜测的准确性

android - 分享内容 : Permission Denial when using Inte

stripe-payments - Stripe Checkout session 后如何在发票上获

java - .rsaEncryptionOAEPSHA256算法在iOS上与Java的兼容性

r - 如何使用 igraph R 包比较两个图以识别两个图之间相同/不同边的数量

json - 使用 JSON Body on Rule 调用 REST API Business C

node.js - 安装react时npm启动问题,如何解决?

firebase - 如何在 flutter 中捕获 StorageException

tensorflow - 如何将 tf.data.Dataset 与 kedro 一起使用?

python - 雪花 Python Okta 连接