majjin

productCard

Oct 6th, 2020 (edited)
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.86 KB | None | 0 0
  1. import 'dart:convert';
  2.  
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:makola_market/Models/product.dart';
  6. import 'package:makola_market/Pages/Content%20Cards/contentCard.dart';
  7. import 'package:makola_market/Pages/productPage.dart';
  8. import 'package:makola_market/constants.dart';
  9.  
  10. class ProductCard extends StatelessWidget {
  11.   final Product product;
  12.  
  13.   ProductCard(this.product);
  14.  
  15.   @override
  16.   Widget build(BuildContext context) {
  17.     return ContentCard(
  18.         GestureDetector(
  19.             onTap: () => Navigator.pushNamed(context, ProductPage.routeName,
  20.                 arguments: product),
  21.             child: Align(
  22.                 alignment: Alignment.centerLeft,
  23.                 child: Text(
  24.                   product.name,
  25.                   style: contentCardText,
  26.                   overflow: TextOverflow.ellipsis,
  27.                 ))),
  28.         GestureDetector(
  29.             onTap: () => Navigator.pushNamed(context, ProductPage.routeName,
  30.                 arguments: product),
  31.             child: Center(
  32.               child: Image(
  33.                   image:
  34.                       MemoryImage(base64Decode(product.imageStr), scale: 1.5)),
  35.             )),
  36.         Row(
  37.           children: [
  38.             Align(
  39.               alignment: Alignment.centerLeft,
  40.               child: Text(
  41.                 '\$${product.price.toStringAsFixed(2)}',
  42.                 style: contentCardText,
  43.               ),
  44.             ),
  45.             Align(
  46.               alignment: Alignment.centerRight,
  47.               child: IconButton(
  48.                 icon: Icon(
  49.                   Icons.add_shopping_cart,
  50.                   size: 28,
  51.                 ),
  52.                 onPressed: null,
  53.               ),
  54.             )
  55.           ],
  56.           mainAxisAlignment: MainAxisAlignment.spaceBetween,
  57.         ));
  58.   }
  59. }
  60.  
Add Comment
Please, Sign In to add comment