Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1. Container(
  2. height: 350.0,
  3. child: ListView.builder(
  4. physics: NeverScrollableScrollPhysics(),
  5. itemCount: 3,
  6. controller: scrollController,
  7. scrollDirection: Axis.horizontal,
  8. itemBuilder: (context, position) {
  9. return GestureDetector(
  10. child: Padding(
  11. padding: const EdgeInsets.all(8.0),
  12. child: Card(
  13. child: Container(
  14. width: 250.0,
  15. child: Column(
  16. crossAxisAlignment: CrossAxisAlignment.start,
  17. mainAxisAlignment:
  18. MainAxisAlignment.spaceBetween,
  19. children: <Widget>[
  20. Padding(
  21. padding: const EdgeInsets.all(8.0),
  22. child: Row(
  23. mainAxisAlignment:
  24. MainAxisAlignment.spaceBetween,
  25. children: <Widget>[
  26. Icon(
  27. cardsList[position].icon,
  28. color: appColors[position],
  29. ),
  30. Icon(
  31. Icons.more_vert,
  32. color: Colors.grey,
  33. )
  34. ],
  35. ),
  36. ),
  37. Padding(
  38. padding: const EdgeInsets.all(8.0),
  39. child: Column(
  40. crossAxisAlignment:
  41. CrossAxisAlignment.start,
  42. children: <Widget>[
  43. Padding(
  44. padding: const EdgeInsets.symmetric(
  45. horizontal: 8.0, vertical: 4.0),
  46. child: Text(
  47. "${cardsList[position].tasksRemaining} Tasks",
  48. style:
  49. TextStyle(color: Colors.grey),
  50. ),
  51. ),
  52. Padding(
  53. padding:
  54. const EdgeInsets.symmetric(
  55. horizontal: 8.0,
  56. vertical: 4.0),
  57. child: Text(
  58. "${cardsList[position].cardTitle}",
  59. style:
  60. TextStyle(fontSize: 28.0),
  61. )),
  62. Padding(
  63. padding: const EdgeInsets.all(8.0),
  64. child: LinearProgressIndicator(
  65. value: cardsList[position]
  66. .taskCompletion,
  67. ),
  68. )
  69. ],
  70. ),
  71. ),
  72. ],
  73. ),
  74. ),
  75. shape: RoundedRectangleBorder(
  76. borderRadius: BorderRadius.circular(10.0)),
  77. ),
  78. ),
  79. onHorizontalDragEnd: (details) {
  80. animationController = AnimationController(
  81. vsync: this,
  82. duration: Duration(milliseconds: 450));
  83. curvedAnimation = CurvedAnimation(
  84. parent: animationController,
  85. curve: Curves.fastOutSlowIn);
  86. animationController.addListener(() {
  87. setState(() {
  88. currentColor =
  89. colorTween.evaluate(curvedAnimation);
  90. });
  91. });
  92.  
  93. if (details.velocity.pixelsPerSecond.dx > 0) {
  94. if (cardIndex > 0) {
  95. cardIndex--;
  96. colorTween = ColorTween(
  97. begin: currentColor,
  98. end: appColors[cardIndex]);
  99. }
  100. } else {
  101. if (cardIndex < 2) {
  102. cardIndex++;
  103. colorTween = ColorTween(
  104. begin: currentColor,
  105. end: appColors[cardIndex]);
  106. }
  107. }
  108. setState(() {
  109. scrollController.animateTo((cardIndex) * 256.0,
  110. duration: Duration(milliseconds: 450),
  111. curve: Curves.fastOutSlowIn);
  112. });
  113.  
  114. colorTween.animate(curvedAnimation);
  115.  
  116. animationController.forward();
  117. });
  118. },
  119. ),
  120. ),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement