如何在颤动中将小部件放置在模式障碍上方?

pip*_*ria 5 flutter flutter-layout

我的设计包含多个列,其中包含多个小部件。

当用户在一列内单击时,屏幕的其余部分应变灰 - 除了该列内处于活动状态的小部件之外。

对于这种“灰色”效果,我使用模态ModalBarrier 类

我怎样才能让一个小部件出现在模式障碍上方? (我的问题是,一切都出现在模态障碍后面......)

在此输入图像描述

Yst*_*ter 4

这个怎么样?

Stack(
    children: [
      new Opacity(
        opacity: 0.3,
        child: const ModalBarrier(dismissible: false, color: Colors.grey),
      ),
      Center(
        child: Container(
          Text('Hello'),
        ),
      ),
    ],
  )
Run Code Online (Sandbox Code Playgroud)

  • 在 ModalBarrier 中,颜色可以具有 Colors.grey.withOpacity(0.3) 的不透明度,从而避免父 Opacity 小部件。 (6认同)