I checked online. Then share the removable widgets of your choice.
The height argument is the default Y-axis position of the widget and the child argument is the widget to display.
The parent container is the Stack. Otherwise you can’t move it
class MoveWidget extends StatefulWidget { final Widget child; final double height; const MoveWidget({Key key, this.child, this.height}) : super(key: key); @override _MoveWidgetState createState() => _MoveWidgetState(); } class _MoveWidgetState extends State<MoveWidget> {double _bottom = 0.0; Double _left = 0.0; double _right; @override voidinitState() {
_bottom = widget.height;
super.initState();
}
@override
Widget build(BuildContext context) {
return Positioned(
left: _left,
right: _right,
bottom:_bottom,
child: Material(
color: Colors.transparent,
child: GestureDetector(
onPanUpdate: (e) {
setState(() {
if(_left ! =null){ _left = _left + e.delta.dx; }else{
_right = _right-e.delta.dx;
}
_bottom = _bottom - e.delta.dy;
});
},
onPanEnd: (DragEndDetails details){
setState(() {
if(_left ! =null){if(_left>MediaQuery.of(context).size.width/2){
_left = null;
_right = 0;
}else{ _left = 0; _right =null; }}else{
if(_right<MediaQuery.of(context).size.width/2){
_left = null;
_right = 0;
}else{ _left = 0; _right =null; }}if(_bottom <MediaQuery.of(context).padding.bottom){ _bottom = MediaQuery.of(context).padding.bottom; }}); }, child: widget.child ?? Container( width: 100, height: 100, color: Colors.red, child: Center(child: Text('No views added')),),),)); }}Copy the code