搜尋套件、儲存庫與 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,
            ),
          ),
        ),
      ],
    ),
  );
}

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。