Skip to content

Instantly share code, notes, and snippets.

@perymerdeka
Created October 24, 2021 16:32
Show Gist options
  • Save perymerdeka/a5f4022b29918b0b57f2fc3ba775a166 to your computer and use it in GitHub Desktop.
Save perymerdeka/a5f4022b29918b0b57f2fc3ba775a166 to your computer and use it in GitHub Desktop.
// ignore_for_file: deprecated_member_use
import 'package:flutter/material.dart';
import '../screens/product_detail_screen.dart';
class ProductItem extends StatelessWidget {
final String id;
final String title;
final String imageUrl;
// ignore: use_key_in_widget_constructors
const ProductItem(this.id, this.title, this.imageUrl);
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.circular(10),
child: GridTile(
child: GestureDetector(
onTap: () {
Navigator.of(context).pushNamed(
ProductDetailScreen.routeName,
arguments: id,
);
},
child: Image.network(
imageUrl,
fit: BoxFit.cover,
),
),
footer: GridTileBar(
backgroundColor: Colors.black87,
leading: IconButton(
icon: const Icon(Icons.favorite_border_outlined),
color: Theme.of(context).accentColor,
onPressed: () {},
),
title: Text(
title,
textAlign: TextAlign.center,
),
trailing: IconButton(
icon: const Icon(
Icons.shopping_cart,
),
onPressed: () {},
color: Theme.of(context).accentColor,
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment