Product List

Loading preview

Starting the Flutter app

Vertical list with thumbnail placeholder, title, price, Add to Cart

Get the source

Add it to your project

Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.

First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.

How it works

Three _products render as ListTiles inside Cards: a 60px tinted square, title and price, and a trailing Add to Cart button. ListView.builder keeps the list lazy. With no onAddToCart, the button counts in _inCart and shows a demo SnackBar. With one, the host owns the cart: the title goes to the callback, and the badge shows cartCount, staying hidden if that’s omitted. There’s no real image.

Adapting it

  • Call your cart logic from onAddToCart, and pass the cart’s size as cartCount.
  • Put a real thumbnail in leading in place of the tinted Container.
  • price is a display string; store a number so carts can do math on it.