Blurred Decoration Image in Flutter

前端 未结 4 831
眼角桃花
眼角桃花 2020-12-25 11:35

I have the background of my app set like so:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Material         


        
4条回答
  •  Happy的楠姐
    2020-12-25 12:36

    You could do something like this, by blurring the container child instead.

    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new MaterialApp(
          home: new Container(
            decoration: new BoxDecoration(
              image: new DecorationImage(
                image: new ExactAssetImage('assets/dog.png'),
                fit: BoxFit.cover,
              ),
            ),
            child: new BackdropFilter(
              filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
              child: new Container(
                decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)),
              ),
            ),
          ),
        );
      }
    }
    

    Screenshot

提交回复
热议问题