实现整个变为示例

Flutter 实现整个App变为灰色的方法示例

编程开发 2020-10-19 02:15:50 38

导读

在Flutter中实现整个App变为灰色是非常简单的,只需要在最外层的控件上包裹ColorFiltered,用法如下:@override Widget build(BuildContext context) { return ColorFiltered( colorFilter: ColorFilter.mode(Colors.grey,&nb……

在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 实现整个App变为灰色的方法示例 

Flutter 实现整个App变为灰色的方法示例


1253067 TFnetwork_cn