Skip to content

Instantly share code, notes, and snippets.

@smarteist
Created March 14, 2020 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarteist/f484a783ecb8dab210cd71ab787aa467 to your computer and use it in GitHub Desktop.
Save smarteist/f484a783ecb8dab210cd71ab787aa467 to your computer and use it in GitHub Desktop.
Its a live blur view for flutter
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