Skip to content

Instantly share code, notes, and snippets.

@florent37
Created July 10, 2019 07:15
Show Gist options
  • Select an option

  • Save florent37/9fb1bd3e2ad61bac5adb4c01d84f22f1 to your computer and use it in GitHub Desktop.

Select an option

Save florent37/9fb1bd3e2ad61bac5adb4c01d84f22f1 to your computer and use it in GitHub Desktop.

Revisions

  1. florent37 created this gist Jul 10, 2019.
    37 changes: 37 additions & 0 deletions BlurredBackground.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    import 'dart:ui';

    import 'package:flutter/material.dart';

    class BlurredBackground extends StatelessWidget {
    final Widget child;
    final Image image;
    final double blurSize;
    final Color maskColor;

    const BlurredBackground({Key key, this.image, this.child, this.blurSize = 5.0, this.maskColor = Colors.transparent}) : super(key: key);

    @override
    Widget build(BuildContext context) {
    return Stack(
    fit: StackFit.expand,
    children: <Widget>[
    this.image,
    Center(
    child: ClipRect(
    child: BackdropFilter(
    filter: ImageFilter.blur(
    sigmaX: this.blurSize,
    sigmaY: this.blurSize
    ),
    child: Container(
    color: this.maskColor,
    alignment: Alignment.center,
    child: this.child,
    ),
    ),
    ),
    ),
    ],
    );
    }
    }