Product Detail

Loading preview

Starting the Flutter app

Collapsing image header, size/color selectors, sticky Add to Cart bar

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

A CustomScrollView pairs a collapsing 300px SliverAppBar with two groups of ChoiceChips. _size holds the chosen label and _color an index into Colors.primaries. Name, price and image are placeholders. With no onAddToCart, the button in bottomNavigationBar counts in _inCart and shows a demo SnackBar. With one, the host owns the cart: the selection goes to the callback, and the badge shows cartCount, staying hidden if that’s omitted.

Adapting it

  • Give ProductDetail a product parameter and use its variants in place of the ['S', 'M', 'L', 'XL'] list.
  • Replace the tinted Container in FlexibleSpaceBar with your product photo.
  • Call your cart service from onAddToCart, and pass its size as cartCount.