搜尋套件、儲存庫與 APP 分類

story_time 封面
套件詳情v1.0.6

story_time

story 的一個分叉,提供類似 Instagram 故事的使用者介面,具備豐富的動畫效果,並且比原封包更具可客製化性。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
135
喜歡數
51
Pub 分數
150

安裝套件

flutter pub add story_time

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Story_time 是一個 Flutter 套件,提供類似 Instagram 的故事介面,相比其原始對應物具有更流暢的動畫和增強的可客製化功能。它讓開發者能夠建立互動式、全螢幕的故事體驗,支援滑動導航、計時器和豐富的媒體支援,適用於多個平台。此套件支援 Android、iOS、Web、macOS、Windows 和 Linux,非常適合需要吸引人的故事式內容顯示的跨平台應用程式。透過廣泛的自訂選項,可細緻調整外觀與行為,以符合多樣化的設計需求。

適用情境

  • 互動故事 feeds
  • 社交媒體應用功能
  • 用戶入門教程
  • 內容亮點集錦
  • 引人入勝的行銷活動

主要特色

  • 豐富的動畫
  • 滑動導航
  • 跨平台支援
  • 高度可自定的使用者介面
  • 基於計時器的故事進展
  • 媒體豐富的故事卡片

適合對象

  • 行動和網頁應用
  • 社交網絡功能
  • 入職體驗
  • 行銷與推廣
  • 創意內容平台

使用建議

  • 需要仔細處理狀態管理
  • 可能影響重媒體的效能
  • 自定樣式需要熟悉 Flutter 小部件
  • 除了基本設置外,文件有限
  • 未針對超長故事序列進行優化

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

story_time

pub package License: MIT

A fork of story. Instagram stories like UI with rich animations and even more customizability than the original package.

final 2

Usage

StoryPageView needs at least three arguments: itemBuilder, pageLength, and storyLength.

/// Minimum example to explain the usage.
return Scaffold(
  body: StoryPageView(
    itemBuilder: (context, pageIndex, storyIndex) {
      return Center(
        child: Text("Index of PageView: $pageIndex Index of story on each page: $storyIndex"),
      );
    },
    storyLength: (pageIndex) {
      return 3;
    },
    pageLength: 4,
  );
  • itemBuilder is necessary to build the content of story. It is called with index of pageView and index of the story on the page.

  • storyLength decides the length of story for each page. The example above always returns 3, but it should depend on the argument pageIndex

  • pageLength is just the length of StoryPageView

The example above just shows 12 stories by 4 pages, which is not practical.

This one is the proper usage, extracted from example.

return Scaffold(
  body: StoryPageView(
    itemBuilder: (context, pageIndex, storyIndex) {
      final user = sampleUsers[pageIndex];
      final story = user.stories[storyIndex];
      return Stack(
        children: [
          Positioned.fill(
            child: Container(color: Colors.black),
          ),
          Positioned.fill(
            child: Image.network(
              story.imageUrl,
              fit: BoxFit.cover,
            ),
          ),
          Padding(
            padding: const EdgeInsets.only(top: 44, left: 8),
            child: Row(
              children: [
                Container(
                  height: 32,
                  width: 32,
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: NetworkImage(user.imageUrl),
                      fit: BoxFit.cover,
                    ),
                    shape: BoxShape.circle,
                  ),
                ),
                const SizedBox(
                  width: 8,
                ),
                Text(
                  user.userName,
                  style: TextStyle(
                    fontSize: 17,
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
          ),
        ],
      );
    },
    gestureItemBuilder: (context, pageIndex, storyIndex) {
      return Align(
        alignment: Alignment.topRight,
        child: Padding(
          padding: const EdgeInsets.only(top: 32),
          child: IconButton(
            padding: EdgeInsets.zero,
            color: Colors.white,
            icon: Icon(Icons.close),
            onPressed: () {
              Navigator.pop(context);
            },
          ),
        ),
      );
    },
    pageLength: sampleUsers.length,
    storyLength: (int pageIndex) {
      return sampleUsers[pageIndex].stories.length;
    },
    onPageLimitReached: () {
      Navigator.pop(context);
    },
  ),
);
  • gestureItemBuilder is the builder for the widgets which needs gesture actions.

In this case, IconButton to close the page is in the callback.

You CANNOT place the gesture widgets in itemBuilder because it is covered and disabled by default story gestures.

  • onPageLimitReached is called when the very last story is finished.

  • It is recommended to use data model with two layers. In this case, UserModel which has the list of StoryModel

/// Example Data Model
class UserModel {
  UserModel(this.stories, this.userName, this.imageUrl);

  final List<StoryModel> stories;
  final String userName;
  final String imageUrl;
}

class StoryModel {
  StoryModel(this.imageUrl);

  final String imageUrl;
}

Controlling animations

My point of forking the original package was to add the ability to control the duration of a specific index of a story. Look at the example to see how to use it if you are interested.

Callbacks for pausing and unpausing stories

The package also supports adding callbacks for pausing and unpausing a story to the StoryPageView widget. See the example project for more details.

Callbacks for moving to a different page

The package also supports adding callbacks for going a page backwards and for going a page forwards to the StoryPageView widget. See the example project for more details.

Callbacks for moving to a different story

The package also supports adding a callback for whenever the story index changes to the StoryPageView widget. See the example project for more details.

Tips

This package is still under development. If you have any requests or questions, please ask on github

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。