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

插件详情v2.0.1

flippable_box

一个双面容器,翻转后可显示两侧内容。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
66
喜欢数
29
Pub 分数
150

安装插件

flutter pub add flippable_box

插件介绍

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

flippable_box 是一个 Flutter 包,提供了一个双面 Container,能够在两个不同的内容面之间翻转。它支持在正面和背面之间实现流畅的动画过渡,非常适合用于交互式 UI 元素,如卡片或翻转效果。该包支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,使其适用于跨平台应用。基于 Flutter 的动画系统构建,提供了响应式且可自定义的翻转行为。

适合场景

  • 交互式卡片界面
  • 产品详情翻转卡片
  • 测验或闪卡应用
  • 动画导航元素
  • 游戏UI组件

主要特点

  • 平滑的3D翻转动画
  • 可自定义的正面和背面内容
  • 跨平台兼容性
  • 与现有控件的轻松集成
  • 支持点击和手势触发

适合对象

  • 开发交互式 UI 的开发者
  • 教育类应用开发者
  • 游戏化应用设计师
  • 寻求动态过渡的设计师

使用建议

  • 可能会影响低端设备的性能
  • 对于复杂内容,需要仔细进行布局管理
  • 仅限基于容器的翻转
  • 不适用于非交互式静态显示

原始 README

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

flippable_box

FlippableBox is a double-sided Container, that holds two pieces of content and automatically re-sizes to match its content, whenever its flipped over.

Usage

First import the package into your class:

import 'package:flippable_box/flippable_box.dart';

Create a FlippableBox with two child Containers. Change the isFlipped property to trigger the internal flip animation.

GestureDetector(
    onTap: () => setState(() => _isFlipped = !_isFlipped),
    child: FlippableBox(
        front: Container(width: 200, height: 200, color: Colors.white),
        back: Container(width: 300, height: 300, color: Colors.white),
        isFlipped: _isFlipped,
    ),
)

NOTE: It is required that the children are Containers, and have their size or constraints set manually, as shown in the example above. This is so the Box knows what its target size is when animating.

To control the flip animation, you can set duration, curve and flipVt which will cause the flip to be in the vertical axis rather than horizontal.

You can also specify a bg which takes a BoxDecoration, and a borderRadius in case you'd like to clip the child contents.

FlippableBox(
    front: child1,
    back: child2,
    isFlipped: _isFlipped,
    borderRadius: 32, //Uses a ClipRRect to clip contents of child containers
    bg: BoxDecoration(color: Colors.white), //Paints the box itself with a shared background
    duration: 0.5, //half second duration
    flipVt: true, //Flip vertically instead of horizontal
    curve: Curves.easeOut,
)

Example

See the example directory for a simple example.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。