Search code examples
flutterflutter-layoutflutter-image

How can I blur the image itself on Flutter?


Recently, I tried to blur the image. But the method using BackDropFilter only makes the blurry effect on the image but doesn't blur the image itself.

What I want to do is to blur the network image itself so it doesn't have a solid border. As you know, with BackDropFilter, the image gets blurred but still has a solid and discontinuous border.

Maybe it doesn't have to be 'blurring image itself' but still I can't figure out how to blur the image with naturally-fading-out border.

Help me please. Thank you


Solution

  • You can either use a Stack where a BackdropFilter covers your image (as suggested by @Narritt), or you can use the ImageFiltered class:

    import 'dart:ui';
    
    // ...
    
    ImageFiltered(
      imageFilter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
      child: Image.network(
        "https://picsum.photos/id/237/200/300",
        fit: BoxFit.cover,
      ),
    )