Last active
January 25, 2022 12:48
-
-
Save FelipeSantos75/f665b7870f200b3e5dd446eef850b98c to your computer and use it in GitHub Desktop.
glass
This file contains 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'; | |
class GlassMorphism extends StatelessWidget { | |
final Widget child; | |
final double start; | |
final double end; | |
const GlassMorphism({ | |
Key? key, | |
required this.child, | |
required this.start, | |
required this.end, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return ClipRRect( | |
child: BackdropFilter( | |
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3), | |
child: Container( | |
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
colors: [ | |
Colors.white.withOpacity(start), | |
Colors.white.withOpacity(end), | |
], | |
begin: AlignmentDirectional.topStart, | |
end: AlignmentDirectional.bottomEnd, | |
), | |
borderRadius: BorderRadius.all(Radius.circular(10)), | |
border: Border.all( | |
width: 1.5, | |
color: Colors.white.withOpacity(0.2), | |
), | |
), | |
child: child, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment