搜索插件、代码仓与 APP 分类

flip_card 封面
插件详情v0.7.0

flip_card

一个提供翻转卡片动画的组件。可用于隐藏和显示产品的详细信息。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
9.6万
喜欢数
956
Pub 分数
135

安装插件

flutter pub add flip_card

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

FlipCard 是一个 Flutter 包,可实现流畅的翻转卡片动画,非常适合展示额外信息(如产品详情)。它支持交互式翻转,并允许自定义前后卡片小部件,是打造引人入胜用户界面的理想选择。该包可在 Android、iOS、Web、macOS、Windows 和 Linux 等所有主要平台上运行,确保行为一致。通过 pub add 简单集成,即可增强 UI 互动性,无需复杂操作。

适合场景

  • 产品详情揭示
  • 互动学习卡片
  • 前后对比
  • 用户资料切换
  • 游戏化UI元素

主要特点

  • 平滑翻转动画
  • 可自定义的正面和背面内容
  • 跨平台支持
  • 与 Flutter 的轻松集成
  • 基于手势的翻转
  • 可配置的速度和方向

适合对象

  • 电子商务应用
  • 教育类应用
  • 交互式教程
  • 仪表板小部件
  • UI 原型设计

使用建议

  • 可能影响低端设备的性能
  • 需要仔细设计以确保可访问性
  • 仅限2D翻转效果
  • 不适用于复杂过渡
  • 动画可能与其他手势冲突

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flip_card PRs Welcome Pub Package

A component that provides a flip card animation. It could be used for hiding and showing details of a product.

How to use

Import the package

import 'package:flip_card/flip_card.dart';
Default

Create a flip card as shown below. By default the card is touch controlled.

You can turn off touch control by setting flipOnTouch to false.

FlipCard(
  fill: Fill.fillBack, // Fill the back side of the card to make in the same size as the front.
  direction: Axis.horizontal, // default
  initialSide: CardSide.front, // The side to initially display.
  front: Container(
    child: Text('Front'),
  ),
  back: Container(
    child: Text('Back'),
  ),
)
Programmatically
Controller (Recommended)

To control the card programmatically, you can pass a controller when creating the card.

late FlipCardController _controller = FlipCardController();

@override
Widget build(BuildContext context) {
  return FlipCard(
    controller: _controller,
    front: ...,
    back: ...,
  );
}

void doStuff() {
  // Flip the card a bit and back to indicate that it can be flipped (for example on page load)
  _controller.hint(
    duration: const Duration(milliseconds: 400),
  );

  // Tilt the card a bit (for example when hovering)
  _controller.skew(0.2);

  // Flip the card programmatically
  _controller.flip();

  // Flip the card to front specifically
  _controller.flip(CardSide.front);

  // Flip the card without animation
  _controller.flipWithoutAnimation();
}
Global Key

You can also control the card via a global key as shown below.

This is not the recommended way.

final cardKey = GlobalKey<FlipCardState>();

@override
Widget build(BuildContext context) {
  return FlipCard(
    key: cardKey,
    flipOnTouch: false,
    front: Container(
      child: RaisedButton(
        onPressed: () => cardKey.currentState.toggleCard(),
        child: Text('Toggle'),
      ),
    ),
    back: Container(
      child: Text('Back'),
    ),
  );
}
Timed

You can auto-flip the widget after a certain delay without any external triggering.

FlipCard(
  fill: Fill.back, // Fill the back side of the card to make in the same size as the front.
  direction: Axis.horizontal, // default
  initialSide: CardSide.front, // The side to initially display.
  front: Container(
    child: Text('Front'),
  ),
  back: Container(
    child: Text('Back'),
  ),
  autoFlipDuration: const Duration(seconds: 2), // The flip effect will work automatically after the 2 seconds
)

所属分类

源码仓库

使用此插件的项目