mirrored_repositories/comprasdoseuze/lib/app/screens/buy_screen
import 'package:comprasdoseuze/app/data/list_products_data.dart';
import 'package:comprasdoseuze/app/models/produto.dart';
import 'package:comprasdoseuze/app/screens/widgets/show_modal.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class ItemListProduct extends StatelessWidget {
  const ItemListProduct({
    Key key,
    @required this.product,
    @required this.listProducts,
  }) : super(key: key);

  final Produto product;
  final List<Produto> listProducts;

  @override
  Widget build(BuildContext context) {
    ListProductData products =
        Provider.of<ListProductData>(context, listen: true);
    print(product.qtdKg.truncateToDouble());
    qtdKg() {
      return product.qtdKg - product.qtdKg.truncateToDouble() == 0.0
          ? (product.qtdKg.truncate())
          : product.qtdKg.toStringAsFixed(2);
    }

    return GestureDetector(
      onTap: () {
        print("object");
        showEditProduct(context, product)
            .then((value) => products.saveData(listProducts));
      },
      child: Dismissible(
        key: UniqueKey(),
        onDismissed: (dismissed) {},
        child: Container(
          child: Padding(
            padding: const EdgeInsets.all(1.0),
            child: Card(
              elevation: 2,
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.all(Radius.circular(8))),
              child: ListTile(
                title: Text(product.descricao),
                trailing: product.check
                    ? Image.asset(
                        "images/check.png",
                        fit: BoxFit.cover,
                        height: 25,
                      )
                    : null,
              ),
            ),
          ),
        ),
      ),
    );
  }
}
