Created
March 9, 2026 15:35
-
-
Save followthemoney1/72222307e75511397688d01c8571108e to your computer and use it in GitHub Desktop.
gradient soft blur effect in flutter. This is how you can use blur effect without frag files and just simple blur effect where on one side its full blurred and on other side of gradient it is not blurred at all
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:ui'; | |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp( | |
| MaterialApp( | |
| home: Scaffold( | |
| body: MyApp(), | |
| ), | |
| ), | |
| ); | |
| } | |
| class MyApp extends StatelessWidget { | |
| final image = 'https://images.unsplash.com/photo-1535892449425-d45bdcb2d016?ixlib=rb-1.2.1&auto=format&fit=crop&w=668&q=80'; | |
| @override | |
| Widget build(BuildContext context) { | |
| return Transform.scale( | |
| scale: 1.2, | |
| child: Stack( | |
| alignment: Alignment.bottomCenter, | |
| fit: StackFit.expand, | |
| children: <Widget>[ | |
| Image.network( | |
| image, | |
| fit: BoxFit.cover, | |
| alignment: Alignment.bottomCenter), | |
| /* BackdropFilter( | |
| filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),*/ | |
| ImageFiltered( | |
| imageFilter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), | |
| child: ShaderMask( | |
| shaderCallback: (rect) { | |
| return LinearGradient( | |
| begin: Alignment.topCenter, | |
| end: Alignment.bottomCenter, | |
| colors: [Colors.black, Colors.black.withOpacity(0)], | |
| stops: [0.4, 0.75]).createShader(rect); | |
| }, | |
| blendMode: BlendMode.dstOut, | |
| child: Image.network( | |
| image, | |
| fit: BoxFit.cover, | |
| alignment: Alignment.bottomCenter), | |
| ) | |
| ), | |
| Container( | |
| decoration: BoxDecoration(gradient: LinearGradient( | |
| begin: Alignment.topCenter, | |
| end: Alignment.bottomCenter, | |
| colors: [Colors.black.withOpacity(0), Colors.black.withOpacity(0.6)], | |
| stops: [0.3, 0.8])) | |
| ) | |
| ])); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
instead you can use this implementation: