This file contains hidden or 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
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Example Animations'), | |
), | |
body: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
firstChild(), |
This file contains hidden or 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
class HomeScreen extends StatefulWidget { | |
@override | |
_HomeScreenState createState() => _HomeScreenState(); | |
} | |
class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin { | |
Animation _arrowAnimation; | |
AnimationController _arrowAnimationController; | |
This file contains hidden or 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
class DragTargetWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return DragTarget(onWillAccept: (data) { | |
return true; | |
}, onAccept: (CardItem data) { | |
if (Provider.of<Data>(context).itemsList.length >= 1) { | |
Provider.of<Data>(context).removeLastItem(); | |
Provider.of<Data>(context).changeSuccessDrop(true); | |
Provider.of<Data>(context).changeAcceptedData(data); |
This file contains hidden or 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
class DraggableWidget extends StatelessWidget { | |
DraggableWidget({ | |
Key key, | |
@required this.i, | |
}) : super(key: key); | |
final int i; | |
CardItem item; |
This file contains hidden or 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
class CardStackWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Stack( | |
alignment: Alignment.center, | |
children: cardItems(context), | |
); | |
} | |
List<Widget> cardItems(BuildContext context) { |
This file contains hidden or 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
class HomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(APP_BAR_TITLE), | |
), | |
floatingActionButton: FloatingActionButton.extended( | |
onPressed: () { | |
Provider.of<Data>(context).initializeDraggableList(); |
This file contains hidden or 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
class Data with ChangeNotifier { | |
bool successDrop; | |
List<CardItem> items; | |
CardItem acceptedData; | |
Data() { | |
successDrop = false; | |
items = Constants.initializeList(items); | |
} |
This file contains hidden or 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
class Constants{ | |
static String SPLASH_SCREEN='SPLASH_SCREEN'; | |
static String HOME_SCREEN='HOME_SCREEN'; | |
static List<CardItem> initializeList(List<CardItem> itemList){ | |
itemList = [ | |
CardItem(content: JAVA, cardColor: BROWN_COLOR), | |
CardItem(content: PHP, cardColor: RED_COLOR), |
This file contains hidden or 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
class CardItem { | |
String content; | |
Color cardColor; | |
double margin; | |
CardItem({this.content, this.cardColor, this.margin}); | |
} |
This file contains hidden or 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
const String APP_BAR_TITLE = 'Drag & Drop Demo'; | |
const String NO_ITEMS_LEFT = 'No Items Left'; | |
const String JAVA = 'Java'; | |
const String PHP = 'PHP'; | |
const String KOTLIN = 'Kotlin'; | |
const String FLUTTER = 'Flutter'; | |
const String NODEJS = 'Nodejs'; | |
const DROP_ITEMS_HERE = 'Drop Items Here'; |