You can use the leading property of ListTile and call your products list inside the container. and inside a container, you can shape your image box. Hope you will get your answer.
import 'package:flutter/material.dart';
class ProductScreen extends StatelessWidget {
final ValueSetter<ProductModel> _valueSetter;
ProductScreen(this._valueSetter);
List<ProductModel> products = [
ProductModel("T-shirt1", 50,""),
ProductModel("T-shirt2", 60,"www.samplepic.com/1"),
ProductModel("T-shirt3", 70,"www.samplepic.com/1"),
ProductModel("T-shirt4", 80,"www.samplepic.com/1"),
ProductModel("T-shirt5", 90,"www.samplepic.com/1"),
];
@override
Widget build(BuildContext context) {
return ListView.separated(
itemBuilder: (context, index) {
return ListTile(
leading: Container(
height: 40,
width: 40,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
shape: BoxShape.rectangle,
image: DecorationImage(
image: NetworkImage(products[index].image),fit: BoxFit.cover,
)
),
),
title: Text(products[index].name),
trailing: Text(
"₺${products[index].price}",
style: const TextStyle(
color: Colors.redAccent,
fontSize: 20,
fontWeight: FontWeight.bold),
),
onTap: () {
_valueSetter(products[index]);
},
);
},
separatorBuilder: (context, index) {
return const Divider();
},
itemCount: products.length);
}
}
class ProductModel{
String name, image;
int price;
ProductModel(this.name, this.price, this.image);