从iOS开发到swift,我能够以模态方式呈现交叉溶解动画并清除背景以显示当前视图背后的内容,并将其模糊为就像弹出窗口一样,如何在Flutter中实现这一点?我使用Fluro导航到下一个视图,淡入过渡效果,但当我将容器和材质小部件颜色更改为透明时,背景为黑色 .
我如何导航到下一页:
IconButton(
icon: Icon(Icons.filter_list),
onPressed: () {
Application.router.define('filter', handler: new Handler(handlerFunc: (context, params) {
return FilterPage(addressIndex, addresses, geoLocation, radius, sortBy, priceMin, priceMax);
}));
Application.router.navigateTo(
context,
'filter',
transition: TransitionType.fadeIn,
);
},
)
过滤页面代码:
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent, // SHOWS BLACK BUT IF I CHANGE TO A COLOR LIKE RED THEN IT SHOWS RED
child: Container(
color: Colors.transparent, // ALLOWS TO SHOW MATERIAL COLOR
padding: EdgeInsets.all(25.0),
child: Stack(
children: <Widget>[
GestureDetector(
onTap: () {
Navigator.pop(context);
},
),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
...
);
更新
我得到了我的目标,但是有一个很大的问题 . 我将过滤器小部件和主容器小部件放在一个 stack()
小部件中,将过滤器小部件置于顶部,但最初的不透明度为0.我想要的效果完美但现在我可以完全覆盖其他小部件...
码:
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0.0,
textTheme: TextTheme(
title: TextStyle(
color: Colors.orangeAccent,
fontWeight: FontWeight.bold,
fontSize: 25.0
),
),
iconTheme: IconThemeData(
color: Colors.black
),
leading: IconButton(
icon: Icon(Icons.menu),
onPressed: () {},
),
title: Text('Jedi'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.filter_list),
onPressed: () {
setState(() {
_isFilterVisible = !_isFilterVisible; // SHOWS/HIDE THE FILTER WIDGET
});
},
),
IconButton(
icon: Icon(Icons.camera_alt),
onPressed: () {},
),
],
),
body: Stack(
children: <Widget>[
Container(
child: ListView.builder(
... // A bunch of rows that needs to be scrolled but can't
//because the BackdropFilter Widget is on top this container
// and just because it's not visible doesn't mean it I can
// interact with what's below it...
),
),
BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
child: AnimatedOpacity(
opacity: _isFilterVisible ? 1.0 : 0.0,
duration: Duration(milliseconds: 200),
child: FilterPage(addressIndex, addresses, geoLocation, radius, sortBy, priceMin, priceMax, () {
setState(() {
_isFilterVisible = !_isFilterVisible;
});
}),
),
),
],
),
);
1 回答
解决方案
您可以通过使用IgnorePointer包围
BackdropFilter
来解决您的交互问题(无法与模糊图像下方的_1579494进行交互) .这意味着IgnorePointer在这里是 solution 因为它将
Widget
作为其子项传递的所有触摸事件都是 ignore .您可以通过更改
ignoring
的bool
值来调整此属性:这将是 enable 所有触摸事件 .
吸收
这里有一些有趣的东西,但与问题无关,是AbsorbPointer
Widget
,它可用于 reflect 发生在其子 onto itself 上的所有触摸事件 .