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

story_view 封面
插件详情v0.16.6

story_view

像 WhatsApp 和 Instagram 一样显示故事。可内联/在 ListView 或 Column 中使用,就像 Google 新闻应用一样。附带手势来暂停、快进和跳转到上一页。

AndroidiOSmacOS
近 30 天下载
2.2万
喜欢数
822
Pub 分数
150

安装插件

flutter pub add story_view

插件介绍

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

StoryView 是一个 Flutter 包,可让开发者显示类似 WhatsApp 和 Instagram 的交互式、可滑动的故事。它支持在列表或列中内联集成,非常适合新闻动态或社交媒体应用。该包内置了暂停、前进和在故事页面间导航的手势。专为跨平台流畅性能设计,可在 Android、iOS 和 macOS 上无缝运行。通过 pub add 进行最少设置,StoryView 即可提供类似原生的故事体验,并支持自定义控件和动画。

适合场景

  • 社交媒体故事动态
  • 新闻应用内容显示
  • 应用内故事功能
  • 用户参与活动
  • 交互式产品导览

主要特点

  • 滑动浏览故事
  • 暂停和恢复功能
  • 基于手势的控制
  • ListView/Column 中的内联放置
  • 跨平台支持(Android、iOS、macOS)

适合对象

  • 需要Instagram风格故事UI的应用
  • 内容密集型应用
  • 以参与度驱动的移动体验
  • 寻求简单故事实现的开发者
  • 需要丰富手势交互的项目

使用建议

  • 可能需要针对长故事序列进行优化
  • 故事卡片设计的自定义选项有限
  • 依赖外部图像/视频加载才能实现完整功能
  • 不适合用于超出基本过渡的复杂动画
  • 使用高分辨率媒体时性能可能有所不同

原始 README

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

story_view Pub

Story view for apps with stories.

story_view

🍟 Watch video demo here: story_view demo

👨‍🚀 Demo project here: storyexample

This a Flutter widget to display stories just like Whatsapp and Instagram. Can also be used inline/inside ListView or Column just like Google News app. Comes with gestures to pause, forward and go to previous page.

Features

🕹 Still image, GIF and video support (with caching enabled)

📍 Gesture for pause, rewind and forward

⚜️ Caption for each story item

🎈 Animated progress indicator for each story item

📱 Fullscreen or inline

And useful callback to perform meta functionalities including vertical swipe gestures.

Installation

To use this plugin, add story_view as a dependency in your pubspec.yaml file.

Usage

Import the package into your code

import "package:story_view/story_view.dart";

Look inside examples/example.dart on how to use this library. You can copy and paste the code into your main.dart and run to have a quick look.

Basics

Use StoryView to add stories to screen or view heirarchy. StoryView requires a list of StoryItem, each of which describes the view to be displayed on each story page, duration and so forth. This gives you the freedom to customize each page of the story.

There are shorthands provided to create common pages.

StoryItem.text is a shorthand to create a story page that displays only text.

StoryItem.pageImage creates a story item to display images with a caption.

StoryItem.inlineImage creates a story item that is intended to be displayed in a linear view hierarchy like List or Column

🍭 Both .inlineImage and pageImage support animated GIFs.

StoryItem.pageVideo creates a page story item with video media. Just provide your video url and get going.

Story controller, loaders and GIF support

While images load, it'll be a better experience to pause the stories until it's done. To achieve this effect, create a global instance of StoryController and use the shorthand StoryItem.pageImage or StoryItem.inlineImage while passing the same controller instance to it.

...
final controller = StoryController();

@override
Widget build(context) {
  List<StoryItem> storyItems = [
    StoryItem.text(...),
    StoryItem.pageImage(...),
    StoryItem.pageImage(...),
    StoryItem.pageVideo(
      ...,
      controller: controller,
    )
  ]; // your list of stories

  return StoryView(
    storyItems,
    controller: controller, // pass controller here too
    repeat: true, // should the stories be slid forever
    onStoryShow: (s) {notifyServer(s)},
    onComplete: () {},
    onVerticalSwipeComplete: (direction) {
      if (direction == Direction.down) {
        Navigator.pop(context);
      }
    } // To disable vertical swipe gestures, ignore this parameter.
      // Preferrably for inline story view.
  )
}

🍭 Now, tell your users some stories.

Docs

Find docs from here: pub.dev/story_view

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目