搜尋套件、儲存庫與 APP 分類

add_to_cart_animation 封面
套件詳情v2.0.4

add_to_cart_animation

一個提供加入購物車動畫的 Flutter 插件。我特別為購物應用準備了它,但您也可以在其他應用中使用。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2730
喜歡數
324
Pub 分數
150

安裝套件

flutter pub add add_to_cart_animation

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 插件,提供流暢的加入購物車動畫,非常適合購物應用程式。它讓使用者能透過動態且吸引人的運動效果,直觀地看到物品被加入購物車。該動畫可自訂,並可整合至各種 UI 元件中。雖然專為電商應用設計,但其彈性足夠適用於其他需要直覺購物車互動的場景。此套件支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 與 Linux。

適用情境

  • 電子商務應用程式產品新增
  • 互動式購物車體驗
  • 項目選擇的視覺反饋
  • 提升零售應用中的使用者參與度
  • 移動和網頁應用中的自定義動畫

主要特色

  • 平滑加入購物車動畫
  • 跨平台相容性
  • 與現有 UI 的輕鬆整合
  • 可自訂的動畫行為
  • 支援多個目標目的地

適合對象

  • 購物和零售應用
  • 需要視覺購物車反饋的應用
  • 尋求簡單動畫解決方案的開發者
  • Flutter 項目針對多個平台
  • 專注於UI/UX增強的開發者

使用建議

  • 需要正確放置購物車圖示或目標
  • 在低階設備上可能需要效能調校
  • 僅限基本購物車動畫模式
  • 不適合複雜的互動流程
  • 依賴正確的元件層級以獲得最佳結果

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Add To Cart Animaiton

A flutter plugin which provide you add to cart animation. I have prepared it to special to shopping apps however you can use it on the others apps too, becasue it accept every widget to drag as in the gif. So It can be useful at shopping, game, news and other category apps.

Icon Preview Gif | Image Preview Gif | Text Preview Gif

Features
  • Product container accepts every widget.
  • The cart and cart's badge can be invisible.
  • The product animation is fully controlled(duration, curve)
  • The first jump animation is fully controlled(active, duration, curve)

If you need it, you can add it to your project easily. It is easy to use

Add the dependency to your pubspec.yaml:

add_to_cart_animation: ^2.0.4

And check the example code to solve how it works.

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});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Add To Cart Animation Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Add To Cart Animation Example'),
      debugShowCheckedModeBanner: false,
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  MyHomePageState createState() => MyHomePageState();
}

class MyHomePageState extends State<MyHomePage> {
  // We can detect the location of the cart by this  GlobalKey<CartIconKey>
  GlobalKey<CartIconKey> cartKey = GlobalKey<CartIconKey>();
  late Function(GlobalKey) runAddToCartAnimation;
  var _cartQuantityItems = 0;

  @override
  Widget build(BuildContext context) {
    return AddToCartAnimation(
      // To send the library the location of the Cart icon
      cartKey: cartKey,
      height: 30,
      width: 30,
      opacity: 0.85,
      dragAnimation: const DragToCartAnimationOptions(
        rotation: true,
      ),
      jumpAnimation: const JumpAnimationOptions(),
      createAddToCartAnimation: (runAddToCartAnimation) {
        // You can run the animation by addToCartAnimationMethod, just pass trough the the global key of  the image as parameter
        this.runAddToCartAnimation = runAddToCartAnimation;
      },
      child: Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
          centerTitle: false,
          actions: [
            //  Adding 'clear-cart-button'
            IconButton(
              icon: const Icon(Icons.cleaning_services),
              onPressed: () {
                _cartQuantityItems = 0;
                cartKey.currentState!.runClearCartAnimation();
              },
            ),
            const SizedBox(width: 16),
            AddToCartIcon(
              key: cartKey,
              icon: const Icon(Icons.shopping_cart),
              badgeOptions: const BadgeOptions(
                active: true,
                backgroundColor: Colors.red,
              ),
            ),
            const SizedBox(
              width: 16,
            )
          ],
        ),
        body: ListView(
          children: List.generate(
            15,
            (index) => AppListItem(
              onClick: listClick,
              index: index,
            ),
          ),
        ),
      ),
    );
  }

  void listClick(GlobalKey widgetKey) async {
    await runAddToCartAnimation(widgetKey);
    await cartKey.currentState!
        .runCartAnimation((++_cartQuantityItems).toString());
  }
}

class AppListItem extends StatelessWidget {
  final GlobalKey widgetKey = GlobalKey();
  final int index;
  final void Function(GlobalKey) onClick;

  AppListItem({super.key, required this.onClick, required this.index});
  @override
  Widget build(BuildContext context) {
    //  Container is mandatory. It can hold images or whatever you want
    Container mandatoryContainer = Container(
      key: widgetKey,
      width: 60,
      height: 60,
      color: Colors.transparent,
      child: Image.network(
        "https://cdn.jsdelivr.net/gh/omerbyrk/add_to_cart_animation/example/assets/apple.png",
        width: 60,
        height: 60,
      ),
    );

    return ListTile(
      onTap: () => onClick(widgetKey),
      leading: mandatoryContainer,
      title: Text(
        "Animated Apple Product Image $index",
      ),
    );
  }
}

By the way, you can run the example project in the plugin to check it deeply.

Have a good days.

Thanks for contributing:

codegtd

Support

Did you find this plugin useful? Please consider to buy me a coffe!

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。