I need to blur a widget, for example, a simple Container. How do I blur it?
new Container(
child: new Text('hello I am here'),
height: 100.0,
width: 100.0,
color: Colors.red,
)
Consider the above Container.
Here is sample code:
import 'dart:ui' as ui;
Widget backdropFilterExample(BuildContext context, Widget child) {
return Stack(
fit: StackFit.expand,
children: <Widget>[
child,
BackdropFilter(
filter: ui.ImageFilter.blur(
sigmaX: 8.0,
sigmaY: 8.0,
),
child: Container(
color: Colors.transparent,
),
)
],
);
}
Google also has sample code on:
https://api.flutter.dev/flutter/widgets/BackdropFilter-class.html
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