Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. class _MenuCard extends StatelessWidget {
  2.  
  3. final String headImageAssetPath;
  4. final IconData icon;
  5. final Color iconBackgroundColor;
  6. final String title;
  7. final String subtitle;
  8. final int heartCount;
  9.  
  10. _MenuCard({
  11. this.headImageAssetPath,
  12. this.icon,
  13. this.iconBackgroundColor,
  14. this.title,
  15. this.subtitle,
  16. this.heartCount,
  17. });
  18.  
  19. @override
  20. Widget build(BuildContext context) {
  21. return new Padding(
  22. padding: const EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0),
  23. child: new Card(
  24. elevation: 10.0,
  25. child: new Column(
  26. children: [
  27. new Image.asset(
  28. headImageAssetPath,
  29. width: double.infinity,
  30. height: 100.0,
  31. fit: BoxFit.cover,
  32. ),
  33. new Row(
  34. children: [
  35. new Padding(
  36. padding: const EdgeInsets.all(15.0),
  37. child: new Container(
  38. padding: const EdgeInsets.all(10.0),
  39. decoration: new BoxDecoration(
  40. color: iconBackgroundColor,
  41. borderRadius: new BorderRadius.all(const Radius.circular(15.0)),
  42. ),
  43. child: new Icon(
  44. icon,
  45. color: Colors.white,
  46. ),
  47. ),
  48. ),
  49. new Expanded(
  50. child: new Column(
  51. crossAxisAlignment: CrossAxisAlignment.start,
  52. children: [
  53. new Text(
  54. title,
  55. style: const TextStyle(
  56. fontSize: 25.0,
  57. fontFamily: 'mermaid',
  58. ),
  59. ),
  60. new Text(
  61. subtitle,
  62. style: const TextStyle(
  63. fontSize: 16.0,
  64. fontFamily: 'bebas-neue',
  65. letterSpacing: 1.0,
  66. color: const Color(0xFFAAAAAA),
  67. ),
  68. ),
  69. ],
  70. ),
  71. ),
  72. new Container(
  73. width: 2.0,
  74. height: 70.0,
  75. decoration: new BoxDecoration(
  76. gradient: new LinearGradient(
  77. colors: [
  78. Colors.white,
  79. Colors.white,
  80. const Color(0xFFAAAAAA),
  81. ],
  82. begin: Alignment.topCenter,
  83. end: Alignment.bottomCenter,
  84. ),
  85. ),
  86. ),
  87. new Padding(
  88. padding: const EdgeInsets.only(left: 15.0, right: 15.0),
  89. child: new Column(
  90. children: [
  91. new Icon(
  92. Icons.favorite_border,
  93. color: Colors.red,
  94. ),
  95. new Text(
  96. '$heartCount',
  97. ),
  98. ],
  99. ),
  100. ),
  101. ],
  102. ),
  103. ],
  104. ),
  105. ),
  106. );
  107. }
  108. }
  109.  
  110. body: new ListView(
  111. children: [
  112. new _MenuCard(
  113. headImageAssetPath: 'images/img.png',
  114. icon: Icons.fastfood,
  115. iconBackgroundColor: Colors.orange,
  116. title: 'il domacca',
  117. subtitle: "78 5TH AVENUE, NEW YORK",
  118. heartCount: 84
  119. ),
  120. new _MenuCard(
  121. headImageAssetPath: 'images/img.png',
  122. icon: Icons.local_dining,
  123. iconBackgroundColor: Colors.red,
  124. title: 'Mc Grady',
  125. subtitle: "79 5TH AVENUE, NEW YORK",
  126. heartCount: 84
  127. ),
  128. new _MenuCard(
  129. headImageAssetPath: 'images/img.png',
  130. icon: Icons.fastfood,
  131. iconBackgroundColor: Colors.purpleAccent,
  132. title: 'Sugar & Spice',
  133. subtitle: "80 5TH AVENUE, NEW YORK",
  134. heartCount: 84
  135. ),
  136. ]
  137. ),
  138.  
  139. class _MenuCard extends StatelessWidget {
  140.  
  141. final String headImageAssetPath;
  142. final IconData icon;
  143. final Color iconBackgroundColor;
  144. final String title;
  145. final String subtitle;
  146. final int heartCount;
  147. final voidCallback onTapCallback; //Add this custom onTap method
  148.  
  149. _MenuCard({
  150. this.headImageAssetPath,
  151. this.icon,
  152. this.iconBackgroundColor,
  153. this.title,
  154. this.subtitle,
  155. this.heartCount,
  156. this.onTapCallback,
  157. });
  158.  
  159. @override
  160. Widget build(BuildContext context) {
  161. return GestureDetector(
  162. onTap: onTapCallback,
  163. child: new Padding(
  164. padding: const EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0),
  165. child: //Rest of your code
  166. ),
  167. );
  168. }
  169.  
  170. }
  171.  
  172. body: new ListView(
  173. children: [
  174. new _MenuCard(
  175. headImageAssetPath: 'images/img.png',
  176. icon: Icons.fastfood,
  177. iconBackgroundColor: Colors.orange,
  178. title: 'il domacca',
  179. subtitle: "78 5TH AVENUE, NEW YORK",
  180. heartCount: 84,
  181. onTapCallback: () {
  182. // Your onTap code goes here
  183. }
  184. ),
  185. // Rest of your code
  186. ]
  187. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement