Skip to content

Instantly share code, notes, and snippets.

@nuelsoft
Created March 24, 2020 17:11
Show Gist options
  • Save nuelsoft/a28330aae65fb0595e6055ff14e76bc5 to your computer and use it in GitHub Desktop.
Save nuelsoft/a28330aae65fb0595e6055ff14e76bc5 to your computer and use it in GitHub Desktop.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
enum Status { on, off }
class _MyHomePageState extends State<MyHomePage> {
Status status = Status.off;
@override
Widget build(BuildContext context) {
return Scaffold(
body: AnimatedContainer(
curve: Curves.easeInOutSine,
duration: Duration(milliseconds: 500),
color: status == Status.on ? Colors.white : Colors.black87,
child: Center(
child: FractionallySizedBox(
heightFactor: .3,
child: Container(
decoration: BoxDecoration(
color: Color(0xffcccccc),
backgroundBlendMode: BlendMode.multiply,
gradient: LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
colors: [Color(0xaacccccc), Color(0xaaffffff)]
),
borderRadius: BorderRadius.circular(40),
boxShadow: [
BoxShadow(color: Color(0xffdddddd), spreadRadius: 4),
BoxShadow(color: Color(0xffeeeeee), spreadRadius: 3),
]),
padding: EdgeInsets.all(2),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
DragTarget(
builder: (context, _, __) {
return status == Status.on
? Draggable(
axis: Axis.vertical,
child: Icon(Icons.blur_circular, size: 70),
feedback: Icon(Icons.blur_circular, size: 70),
childWhenDragging: Container(
height: 0,
width: 0,
),
)
: Container(height: 70, width: 70);
},
onAccept: (d) {
setState(() {
status = Status.on;
});
},
),
DragTarget(
builder: (context, _, __) {
return status == Status.off
? Draggable(
axis: Axis.vertical,
child: Icon(Icons.blur_circular, size: 70),
feedback: Icon(Icons.blur_circular, size: 70),
childWhenDragging: Container(
height: 0,
width: 0,
),
)
: Container(height: 70, width: 70);
},
onAccept: (d) {
setState(() {
status = Status.off;
});
},
)
],
),
),
)),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment