패키지, 저장소 및 앱 카테고리 검색

add_to_cart_animation 표지
패키지 상세v2.0.4

add_to_cart_animation

카트에 추가하는 애니메이션을 제공하는 플러터 플러그인입니다. 저는 이를 쇼핑 앱 전용으로 준비했지만 다른 앱에서도 사용할 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
2.7천
좋아요
324
Pub 점수
150

패키지 설치

flutter pub add add_to_cart_animation

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

쇼핑 애플리케이션에 적합한 부드러운 장바구니 추가 애니메이션을 제공하는 플러터 플러그인입니다. 사용자가 아이템이 장바구니에 추가되는 것을 동적이고 매력적인 움직임으로 시각적으로 경험할 수 있도록 합니다. 애니메이션은 사용자 정의가 가능하며 다양한 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!

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.