Created
March 14, 2020 19:13
-
-
Save smarteist/f484a783ecb8dab210cd71ab787aa467 to your computer and use it in GitHub Desktop.
Its a live blur view for flutter
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/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
// ignore: must_be_immutable | |
class MovableStackItem extends StatefulWidget { | |
Widget _child; | |
double _radius; | |
Color _color; | |
Widget get getChild => _child; | |
double get getRadius => _radius; | |
Color get getColor => _color; | |
MovableStackItem( | |
{Widget child, | |
Color color = Colors.transparent, | |
double blurRadius = 15.0}) { | |
_child = child; | |
_color = color; | |
_radius = blurRadius; | |
} | |
@override | |
State<StatefulWidget> createState() { | |
return MovableStackItemState(this); | |
} | |
} | |
class MovableStackItemState extends State<MovableStackItem> { | |
MovableStackItem parent; | |
double xPosition = 0; | |
double yPosition = 0; | |
MovableStackItemState(this.parent); | |
@override | |
void initState() { | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Positioned( | |
top: yPosition, | |
left: xPosition, | |
child: GestureDetector( | |
onPanUpdate: (tapInfo) { | |
setState(() { | |
xPosition += tapInfo.delta.dx; | |
yPosition += tapInfo.delta.dy; | |
}); | |
}, | |
child: ClipRect( | |
child: BackdropFilter( | |
filter: ImageFilter.blur( | |
sigmaX: parent._radius, sigmaY: parent._radius), | |
child: Container( | |
color: parent.getColor, | |
child: parent.getChild, | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment