how can i use BackdropFilter in flutter for Appbar ? when i use that for the Appbarother widgets which they are into Scaffold blurred, not AppBar
for example:
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 5,
sigmaY: 5
),
child: AppBar(
automaticallyImplyLeading: false,
// Used for removing back button.
elevation: 8.0,
titleSpacing: 0.0,
backgroundColor: theme.appMainColor,
title: Stack(
children: <Widget>[
],
)),
),
After searching web for a while and trying different combinations of widgets, I finally found the solution
appBar: PreferredSize(
child: Container(
child: ClipRRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: Container(
// width: MediaQuery.of(context).size.width,
// height: MediaQuery.of(context).padding.top,
color: Colors.transparent,
))),
),
preferredSize: Size(MediaQuery.of(context).size.width, 22),
),
Go nuts!!
AppBar.BackDropFilter with a ClipRect to prevent the blur from getting all over the screen.Container as the child of the BackDropFilterHere is the minimal code you'll need to add to your AppBar:
flexibleSpace: ClipRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 7, sigmaY: 7),
child: Container(
color: Colors.transparent,
),
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With