如何在Flutter中实现Modal Bottome Sheet的模糊背景?

zmx*_*gh2 6 flutter

我正在使用 Modal Bottom 工作表,想要给出模糊的背景,但参数Barriercolor的类型是 Color,所以我不能使用 BackdropFiter()。有谁知道如何为模态底板实现模糊背景?

iwp*_*wpz 15

更新:
抱歉我的粗心。
您可以在 中设置backgroundColor:Colors.transparentexpand:true制作自己的。barrierbuilder

它可能看起来像这样:

showMaterialModalBottomSheet(
      context: context,
      backgroundColor: Colors.transparent,
      expand: true,
      builder: (context) => BackdropFilter(
        filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            Container(
              height: 200,
              width: MediaQuery.of(context).size.width,
              color: Colors.white,
              child: Text('Im child'),
            )
          ],
        ),
      ),
    );
Run Code Online (Sandbox Code Playgroud)

  • 感谢您的快速回复,但这与我想要的完全不同。我希望屏障部分模糊,而不是纸张部分。 (2认同)