パッケージ、リポジトリ、アプリカテゴリを検索

story のカバー
パッケージ詳細v1.1.0

story

Instagram ストーリーのようなUIで、豊富なアニメーションとカスタマイズ性を備えています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
9430
いいね数
348
Pub ポイント
150

パッケージをインストール

flutter pub add story

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

ストーリー パッケージは、Instagram ストーリーズをインスパイアした UI を提供し、スムーズなアニメーションと高いカスタマイズ性を備えています。開発者がカスタマイズ可能な遷移、タイマー、コンテンツレイアウトを持つインタラクティブでスワイプ可能なストーリーカードを作成できるようにします。ダイナミックな物語体験が必要なアプリに最適で、モバイル、Web、デスクトップを含む複数のプラットフォームをサポートしています。Flutter のウィジェットシステムとの統合が容易であり、外観および動作の両方に対して広範なスタイルオプションを提供しています。

用途

  • ソーシャルメディア風のストーリー・フィードを作成する
  • インタラクティブなチュートリアルやオンボーディングフローの構築
  • 期間限定のコンテンツ更新を表示する
  • 魅力的なマーケティングキャンペーンの設計
  • ユーザー・プロフィールのストーリー・ハイライトを実装する

主な機能

  • 豊かでアニメーションされたストーリーの遷移
  • カスタマイズ可能なストーリーカードレイアウト
  • 複数プラットフォーム間でのスワイプジェスチャー対応
  • 設定可能な期間と進行状況インジケーター
  • 拡張可能なテーマとスタイルオプション

適している対象

  • ソーシャル機能を開発する開発者
  • 時間制限付きのコンテンツ配信を必要とするアプリ
  • アニメーション付きUIコンポーネントを探しているデザイナー
  • 物語のようなインターフェースを備えたクロスプラットフォームアプリケーション

注意事項

  • ナビゲーション中に状態を慎重に扱う必要があります
  • 大規模なストーリーセットではパフォーマンスに影響を与える可能性があります
  • 限定された組み込みの分析またはトラッキング
  • 非常に長い物語には最適化されていません
  • 高度な効果には外部アニメーションライブラリに依存しています

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

version likes popularity License: MIT all contributors

Instagram stories like UI with rich animations and customizability.

final 2

Usage

StoryPageView requires 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 builds the content of each story and is called with the index of the pageView and the 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 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 builds widgets that need gesture actions

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

You CANNOT place the gesture widgets in itemBuilder as they are covered and disabled by the 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;
}
StoryImage

If you show images in StoryPageView, use StoryImage. It can stop the indicator until the image is fully loaded.

StoryImage(
  /// key is required
  key: ValueKey(story.imageUrl),
  imageProvider: NetworkImage(
    story.imageUrl,
  ),
  fit: BoxFit.fitWidth,
)

Be sure to assign the unique key value for each image, otherwise the image loading will not be handled properly.

indicatorAnimationController

If you stop/start the animation of the story with your custom widgets, use indicatorAnimationController

class _StoryPageState extends State<StoryPage> {
  late ValueNotifier<IndicatorAnimationCommand> indicatorAnimationController;

  @override
  void initState() {
    super.initState();
    indicatorAnimationController = ValueNotifier<IndicatorAnimationCommand>(
        IndicatorAnimationCommand.resume);
  }

  @override
  void dispose() {
    indicatorAnimationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StoryPageView(
        indicatorAnimationController: indicatorAnimationController,
        ...,
      ),
    );
  }
}

Once the instance is passed to StoryPageView, you can stop handle the indicator by the methods below.


/// To pause the indicator
indicatorAnimationController.value = IndicatorAnimationCommand.pause;

/// To resume the indicator
indicatorAnimationController.value = IndicatorAnimationCommand.resume;

Contributors

Santa Takahashi
Santa Takahashi

💻
Isaias Mejia de los Santos
Isaias Mejia de los Santos

💻
Медик
Медик

💻
Alperen Soysal
Alperen Soysal

💻
AtixD
AtixD

💻
harshitFinmapp
harshitFinmapp

💻
dmitry-kotorov
dmitry-kotorov

💻
sachin kumar rajput
sachin kumar rajput

💻
Mohamed Othman
Mohamed Othman

💻

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト