Skip to content
pubscout

flutter_cart

0.0.9, released 3 years ago by an unverified publisher

Flutter package for managing a shopping cart with add/remove, quantity updates, totals and optional persistence.

WASM-readyUnverified publisher
$ flutter pub add flutter_cart
Source repository

What it does

It provides a FlutterCart class to initialize, add items, update quantities, remove items, clear the cart, apply discounts, and retrieve totals and item lists. Persistence can be enabled via shared_preferences.

AI-written summary of version 0.0.9, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need a lightweight cart solution without pulling in a full state‑management library
  • You want simple persistence of cart data across app launches

Skip it when

  • You require reactive streams or Bloc‑style state updates
  • You need secure or encrypted storage for cart data
  • Your cart data is large or relational and needs a database

Strengths

  • Very easy to integrate and use
  • Optional persistence with shared_preferences
  • No code generation required

Weaknesses

  • Only key‑value persistence, not suitable for large data sets
  • No built‑in reactive or stream API
  • No UI widgets provided

Setup

Kind
Flutter widgets
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
3

Call FlutterCart().initializeCart(isPersistenceSupportEnabled: true) before runApp; ensure shared_preferences is added (already a dependency).

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  var cart = FlutterCart();
  await cart.initializeCart(isPersistenceSupportEnabled: true);
  runApp(MyApp());
}

// Adding an item
cart.addToCart(cartModel: CartModel(productId: 'p1', quantity: 1, price: 9.99));

Alternatives

Packages that do the same job and could replace flutter_cart.

  • sqflite

    Provides a full SQLite database for larger or more complex cart data and supports queries beyond simple key‑value storage

Works with

Packages commonly used together with flutter_cart: ones it builds on, ones built on it, and its own family.