Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. class DragTargetWidget extends StatelessWidget {
  2. @override
  3. Widget build(BuildContext context) {
  4. return DragTarget(onWillAccept: (data) {
  5. return true;
  6. }, onAccept: (CardItem data) {
  7. if (Provider.of<Data>(context).itemsList.length >= 1) {
  8. Provider.of<Data>(context).removeLastItem();
  9. Provider.of<Data>(context).changeSuccessDrop(true);
  10. Provider.of<Data>(context).changeAcceptedData(data);
  11. }
  12. }, builder: (context, List<CardItem> cd, rd) {
  13. if (Provider.of<Data>(context).isSuccessDrop) {
  14. return Padding(
  15. padding: const EdgeInsets.all(25.0),
  16. child: Stack(
  17. children:
  18. buildTargetList(Provider.of<Data>(context).getAcceptedData),
  19. ),
  20. );
  21. } else {
  22. return Padding(
  23. padding: const EdgeInsets.all(25.0),
  24. child: DottedBorder(
  25. color: Colors.black,
  26. gap: 3,
  27. strokeWidth: 1,
  28. child: Container(
  29. height: 200.0,
  30. width: 200.0,
  31. color: Colors.grey[400],
  32. child: Card(
  33. shape: RoundedRectangleBorder(
  34. borderRadius: BorderRadius.circular(5)),
  35. color: Colors.grey[400],
  36. child: Center(
  37. child: Text(
  38. DROP_ITEMS_HERE,
  39. style: TextStyle(color: Colors.black, fontSize: 22.0),
  40. ),
  41. ),
  42. )),
  43. ),
  44. );
  45. }
  46. });
  47. }
  48.  
  49. List<Widget> buildTargetList(CardItem cardItem) {
  50. List<Widget> targetList = [];
  51. targetList.add(
  52. DottedBorder(
  53. gap: 3,
  54. strokeWidth: 1,
  55. color: Colors.black,
  56. child: Container(
  57. height: 200.0,
  58. width: 200.0,
  59. child: Card(
  60. shape: RoundedRectangleBorder(
  61. borderRadius: BorderRadius.circular(10.0)),
  62. color: cardItem.cardColor,
  63. child: Center(
  64. child: Text(
  65. '${cardItem.content}',
  66. style: TextStyle(fontSize: 25.0, color: WHITE_COLOR),
  67. )),
  68. ),
  69. ),
  70. ),
  71. );
  72. return targetList;
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement