Flutter 实现整个App变为灰色

503 阅读1分钟

在Flutter中实现整个App变为灰色是非常简单的,只需要在最外层的控件上包裹ColorFiltered,用法如下:

@override
Widget build(BuildContext context) {
  return ColorFiltered(
      colorFilter: ColorFilter.mode(Colors.grey, BlendMode.color),
      child: Scaffold(
        appBar: _appBar,
        body: IndexedStack(
          index: _currIndex,
          children: <Widget>[HomeItemPage(), WidgetPage(), MyPage()],
        ),
        backgroundColor: Theme.of(context).backgroundColor,
        bottomNavigationBar: _buildBottomNavigationBar(context),
      ));
}

前后效果对比如下:

交流

Flutter地址:laomengit.com 里面包含160多个组件的详细用法。