draggable_widget 1.0.0 draggable_widget: ^1.0.0 copied to clipboard
A new Flutter package project.
import 'package:draggable_widget/draggable_widget.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
DragController dragController = DragController();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FlatButton(
onPressed: () {
dragController.showWidget();
},
child: Text("Show"),
),
FlatButton(
onPressed: () {
dragController.hideWidget();
},
child: Text("Hide"),
),
FlatButton(
onPressed: () {
dragController.jumpTo(AnchoringPosition.topRight);
},
child: Text("Move to Top Right"),
),
FlatButton(
onPressed: () {
dragController.jumpTo(AnchoringPosition.topLeft);
},
child: Text("Move to Top Left"),
),
FlatButton(
onPressed: () {
dragController.jumpTo(AnchoringPosition.bottomRight);
},
child: Text("Move to bottom Right"),
),
FlatButton(
onPressed: () {
dragController.jumpTo(AnchoringPosition.bottomLeft);
},
child: Text("Move to Bottom Left"),
),
],
),
),
Container(
height: 80,
width: double.infinity,
color: Colors.green,
),
DraggableWidget(
bottomMargin: 80,
topMargin: 80,
intialVisibility: true,
horizontalSapce: 20,
shadowBorderRadius: 50,
child: Container(
height: 100,
width: 100,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.blue,
),
),
initialPosition: AnchoringPosition.bottomLeft,
dragController: dragController,
)
],
),
);
}
}