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

coast 封面
插件详情v2.0.2

coast

支持类似 Hero 动画的 PageView 包装器

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
875
喜欢数
96
Pub 分数
140

安装插件

flutter pub add coast

插件介绍

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

Coast 是一个 Flutter 包,它扩展了 PageView 以在页面之间实现类似 Hero 的动画,提供流畅且视觉上吸引人的过渡效果。它通过自动管理动画生命周期,简化了跨页面边界共享元素过渡的实现。适用于具有卡片式导航或内容密集型界面的应用程序,其中屏幕之间的连续性可以提升用户体验。该包支持所有主要平台,确保在各种设备上行为一致。

适合场景

  • 基于卡片的导航
  • 内容密集型应用界面
  • 平滑的屏幕过渡
  • PageView 中的 Hero 类动画
  • 跨页面共享元素动画

主要特点

  • 自动处理类似 Hero 的动画
  • 与 PageView 的无缝集成
  • 跨平台支持
  • 最小化样板代码
  • 支持共享元素过渡

适合对象

  • 寻求流畅页面过渡的开发者
  • 具有动态内容流的应用程序
  • 以用户界面为重点的应用程序
  • 需要视觉连续性的Flutter项目
  • 注重动画一致性的团队

使用建议

  • 可能会影响重型组件的性能
  • 需要仔细的 Widget 结构才能获得最佳效果
  • 与手动设置 Hero 相比,自定义选项有限
  • 最适合中等复杂度的过渡
  • 不太适合高度复杂的动画链

原始 README

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

coast

build

PageView wrapper supporting Hero-like animations

img/example

Example

Create a Coast with a number of Beaches and add a CrabController as observer to the Coast. Wrap a widget that you want to animate between beaches with a Crab widget with the same tag.

class CoastExampleApp extends StatefulWidget {
  @override
  _CoastExampleAppState createState() => _CoastExampleAppState();
}

class _CoastExampleAppState extends State<CoastExampleApp> {
  final _beaches = [
    Beach(builder: (context) => Cadzand()),
    Beach(builder: (context) => Westkapelle()),
    Beach(builder: (context) => Zoutelande()),
  ];

  final _coastController = CoastController();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Coast(
        beaches: _beaches,
        controller: _coastController,
        observers: [
          CrabController(),
        ],
      ),
    );
  }
}


class Cadzand extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(
      title: Text("Cadzand"),
      backgroundColor: Colors.deepOrange,
    ),
    body: Stack(
      children: [
        Positioned(
          top: 40,
          left: 40,
          child: Crab(
            tag: "container",
            child: Container(
              color: Colors.green,
              width: 80,
              height: 60,
            ),
          ),
        ),
      ],
    ),
  );
}

class Westkapelle extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(
      title: Text("Westkapelle"),
      backgroundColor: Colors.amber,
    ),
    body: Stack(
      children: [
        Positioned(
          top: 80,
          right: 40,
          child: Crab(
            tag: "container",
            child: Container(
              color: Colors.green,
              width: 200,
              height: 100,
            ),
          ),
        ),
      ],
    ),
  );
}

class Zoutelande extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(
      title: Text("Zoutelande"),
      backgroundColor: Colors.deepPurple,
    ),
    body: Stack(
      children: [
        Positioned(
          bottom: 40,
          left: 20,
          child: Crab(
            tag: "container",
            child: Container(
              color: Colors.green,
              width: 100,
              height: 200,
            ),
          ),
        ),
      ],
    ),
  );
}

所属分类

源码仓库

使用此插件的项目

暂无相关数据。