add_to_cart_animation
2.0.4, released 2 years ago by omerbayrak.me
Provides add‑to‑cart animation for any widget in Flutter apps.
WASM-ready
What it does
The package lets you animate any widget moving into a cart icon, with optional badge updates. It offers configurable drag and jump animations, duration, and curves.
AI-written summary of version 2.0.4, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a visual add‑to‑cart effect in a shopping or gamified UI
- You want a ready‑made, cross‑platform animation without writing custom code
Skip it when
- The UI is static and no cart interaction is required
- You need a highly custom animation beyond the provided options
Strengths
- Simple API – just provide a GlobalKey and call the run function
- Works on Android, iOS, web, desktop out of the box
- Customizable duration, curve and badge visibility
Weaknesses
- Focused only on cart‑style animations, not a general animation framework
- May add extra widget hierarchy and performance cost for simple lists
- Limited documentation beyond the example
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:add_to_cart_animation/add_to_cart_animation.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) => MaterialApp(home: const DemoPage());
}
class DemoPage extends StatefulWidget {
const DemoPage({super.key});
@override
State<DemoPage> createState() => _DemoPageState();
}
class _DemoPageState extends State<DemoPage> {
final GlobalKey<CartIconKey> cartKey = GlobalKey<CartIconKey>();
late Function(GlobalKey) runAddToCart;
int items = 0;
@override
Widget build(BuildContext context) => AddToCartAnimation(
cartKey: cartKey,
createAddToCartAnimation: (run) => runAddToCart = run,
child: Scaffold(
appBar: AppBar(
title: const Text('Demo'),
actions: [AddToCartIcon(key: cartKey)],
),
body: ListTile(
leading: Container(
key: GlobalKey(),
width: 60,
height: 60,
child: const Icon(Icons.shopping_bag),
),
title: const Text('Item'),
onTap: () async {
await runAddToCart(GlobalKey());
await cartKey.currentState!.runCartAnimation((++items).toString());
},
),
),
);
}
Alternatives
Packages that do the same job and could replace add_to_cart_animation.
- flutter_animate
General purpose animation library with many effects and a declarative API
70Compare - loading_animation_widget
Provides ready‑made loading animations if you only need simple visual feedback
50Compare