搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。