Unverified Commit 6e92f87d authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[framework] document backdropfilter antipattern (#109340)

parent 3f5a2534
...@@ -493,6 +493,45 @@ class ShaderMask extends SingleChildRenderObjectWidget { ...@@ -493,6 +493,45 @@ class ShaderMask extends SingleChildRenderObjectWidget {
/// [ImageFiltered] instead. For that scenario, [ImageFiltered] is both /// [ImageFiltered] instead. For that scenario, [ImageFiltered] is both
/// easier to use and less expensive than [BackdropFilter]. /// easier to use and less expensive than [BackdropFilter].
/// ///
/// {@tool snippet}
///
/// This example shows how the common case of applying a [BackdropFilter] blur
/// to a single sibling can be replaced with an [ImageFiltered] widget. This code
/// is generally simpler and the performance will be improved dramatically for
/// complex filters like blurs.
///
/// The implementation below is unnecessarily expensive.
///
/// ```dart
/// Widget buildBackdrop() {
/// return Stack(
/// children: <Widget>[
/// Positioned.fill(child: Image.asset('image.png')),
/// Positioned.fill(
/// child: BackdropFilter(
/// filter: ui.ImageFilter.blur(sigmaX: 6, sigmaY: 6),
/// ),
/// ),
/// ],
/// );
/// }
/// ```
/// {@end-tool}
/// {@tool snippet}
/// Instead consider the following approach which directly applies a blur
/// to the child widget.
///
/// ```dart
/// Widget buildFilter() {
/// return ImageFiltered(
/// imageFilter: ui.ImageFilter.blur(sigmaX: 6, sigmaY: 6),
/// child: Image.asset('image.png'),
/// );
/// }
/// ```
///
/// {@end-tool}
///
/// See also: /// See also:
/// ///
/// * [ImageFiltered], which applies an [ImageFilter] to its child. /// * [ImageFiltered], which applies an [ImageFilter] to its child.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment