Story view for apps with stories.

Overview

story_view Pub

Story view for apps with stories.

๐Ÿ‘จโ€๐Ÿš€ Demo project here: storyexample

๐ŸŸ Watch video demo here: story_view demo Youtube

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

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.

Comments
  • Video Duration Problem

    Video Duration Problem

    Hi,

    I am using this awesome plugin but I have got an issue which is that I cant set the duration of the story item according to the duration of the video even though I am using the same controller instance in both of the story view & story item.

    I hope you find a solution to this.

    Thanks

    opened by boucoding 10
  • Get the duration from the actual video duration

    Get the duration from the actual video duration

    This problem is only regarding video stories. There should be a way to specify the video story duration based on the duration of the actual video. For that, I think the videoplayercontroller.value.duration should be used as the default duration for video stories if any duration is not passed explicitly.

    opened by IAmSarthakVerma 9
  • Can we change Story items as Different Widgets?

    Can we change Story items as Different Widgets?

    Hi Sir, This is not an issues . I have an idea to add a new features in story_view. Can we add a new features for changing the different Widgets as stories items...If this is possible.

    opened by rahulkushwaha-techconfer 7
  • get feedback when video finished loading on StoryItem

    get feedback when video finished loading on StoryItem

    I have added functionality to get feedback when video finished loading on StoryItem in order to play storyController only when video is start playing for real.

    opened by quetool 7
  • First item is getting played twice in iOS simulator. In Android it works fine.

    First item is getting played twice in iOS simulator. In Android it works fine.

    I have tested this iPhone 11 Pro Max and iPhone 8 Plus simulators. Placing my code below.

      @override
      Widget build(BuildContext context) {
        List<StoryItem> storyItems = _imageUrls.map((imageUrl) {
          return StoryItem.pageImage(CachedNetworkImageProvider(imageUrl));
        }).toList();
    
        return Scaffold(
          body: Stack(
            children: <Widget>[
              StoryView(
                storyItems,
                controller: controller, // pass controller here too
                repeat: true, // should the stories be slid forever
                onStoryShow: (s) {
                  print("onStoryShow->${s.view}");
                },
              ),
              SafeArea(
                child: Column(
                  children: <Widget>[
                    SizedBox(height: 16,),
                    Row(
                      children: <Widget>[
                        IconButton(
                          icon: Icon(Icons.close,color: Colors.white,),
                          onPressed: () {
                            Navigator.pop(context);
                          },
                        )
                      ],
                    )
                  ],
                ),
              )
            ],
          ),
        );
      }
    
    opened by raziq10000 5
  • Send Metadata to use in `onStoryShow`

    Send Metadata to use in `onStoryShow`

    Currently, there isn't any possibility of marking as read on server side. This functionality will allow to do some operation (maybe, an API call to backend) with the available metadata.

    opened by avvari-da 5
  • How to handle a click on a button inside a story?

    How to handle a click on a button inside a story?

    Thanks a lot for the plugin. I created a button inside Stories, but it doesn't work. When I press the button, I go to the next story. How to handle a button click?

    ะกะฝะธะผะพะบ ัะบั€ะฐะฝะฐ 2021-09-06 ะฒ 12 03 58

    opened by petrovyuri 4
  • Slide down gesture pauses the story

    Slide down gesture pauses the story

    Hi,

    I am using your package for both images and videos. I am facing an issue when i swipe up or down on the screen (basically any action apart from tap), the story pauses and never resumes. Is there anyway to not register the swipe as a gesture/action? I.e. the story continues to play even if there is any slide/swipe gesture on the screen?

    Thank you !

    opened by seeratcheema93 4
  • swipe down gesture to dismiss storyview

    swipe down gesture to dismiss storyview

    Just like Instagram & snapchat stories, we need to be able to swipe the screen down and be able to dismiss the page with possibly a fade + scale + translate transition.

    opened by aytunch 4
  • Upgrade rxdart version  to ^0.27.1

    Upgrade rxdart version to ^0.27.1

    Upgrade rxdart version from ^0.26.0 to ^0.27.1.

    As I'm using stopwatch timer which uses rxdart ^0.27.1. There is an compatible issue

    Because stop_watch_timer >=1.3.0 depends on rxdart ^0.27.1 and story_view 0.13.1 depends on rxdart ^0.26.0, stop_watch_timer >=1.3.0 is incompatible with story_view 0.13.1.

    opened by moaabid 3
  • Nullsafety version does not work

    Nullsafety version does not work

    App crashes with error:

    type '() => Null' is not a subtype of type '(() => StoryItem)?' of 'orElse'

    throw from this part:

    final firstPage = widget.storyItems.firstWhere((it) {
          return !it!.shown;
        }, orElse: () {
          widget.storyItems.forEach((it2) {
            it2!.shown = false;
          });
    
          return null;
        });
    

    example:

    @override
      Widget build(BuildContext context) {
          final storyItems = <StoryItem>[
            StoryItem.text(title: "page1", backgroundColor: Colors.red),
            StoryItem.text(title: "page2", backgroundColor: Colors.red),
            StoryItem.text(title: "page3", backgroundColor: Colors.red),
            StoryItem.text(title: "page4", backgroundColor: Colors.red),
          ];
    
        return StoryView(storyItems: storyItems, controller: storyController);
      }
    opened by Thioby 3
  • First item is getting played thrice

    First item is getting played thrice

    Hello,

    Whenever I open the stories, the first story's onStoryShow: (StoryItem storyItem) {} is called 3 times. It happens for whichever story you open for the first time, from the second story onwards, it's called single time only.

    I have checked the parent widgets, they are never being called 3 times, it's only happening inside onStoryShow() callback. Also, I have checked the solution in https://github.com/blackmann/story_view/issues/14 but I am already following the same practice of defining the storyItems in initstate.

    Here are some logs with timestamps: flutter: onStoryShow() -> storyID: 18. timestamp: 2023-01-07 16:10:02.302414. flutter: onStoryShow() -> storyID: 18. timestamp: 2023-01-07 16:10:02.359484. flutter: onStoryShow() -> storyID: 18. timestamp: 2023-01-07 16:10:02.600755.

    Please help.

    opened by rahuldubey093 0
  • Use FractionallySizedBox to set width to half of parent

    Use FractionallySizedBox to set width to half of parent

    Screenshot 2022-10-27 at 6 53 10 PM

    Current issue: Width of GestureDetector is not exactly half of the parent. Issue caused by the fix width set using SizedBox at 70px.

    Fix: To use FractionallySizedBox to set widthFactor as half. Tested on both iOS and Redmi (Android) device.

    opened by jadenwjh 0
  • Had to double tap the slide to go to previous slide

    Had to double tap the slide to go to previous slide

    I have a story view that has many slides.

    Going to the next slide on tap on the image works fine. but when I try to go to the previous slide, it just resets the sliding duration of the current slider. And I tap it again, and it goes to the previous slide.

    Is anyone else facing this issue?

    My code:

            StoryViewer(
                  key: UniqueKey(),
                  viewerController: controller,
                  customValues: Customizer(
                    sendIcon: Icons.send,
                    closeIcon: Icons.close,
                    replyPlaceholder: "Message",
                  ),
                  hasReply: false,
                  trusted: true,
                  loop: false,
                  progressBorderRadius:
                      const BorderRadius.all(Radius.circular(12)),
                  progressRowPadding: const EdgeInsets.all(10),
                  progressHeight: 6,
                  backgroundColor: kGreyColor,
                  mediaAlignment: Alignment.center,
                  // auto go back if the aspect ratio is StoryRatio.r9_16
                  // ratio: StoryRatio.r4_3,
                  stories: storyItems,
                  userModel: UserModel(
                    username: widget.story.name,
                    profilePicture: NetworkImage(widget.story.profileImage),
                  ),
                  onEachStoryLoadComplated: ({String? storyID}) {
                    print(storyID);
                  },
                ),
    
    opened by imsujan276 0
  • Story View pauses when loading Second Story

    Story View pauses when loading Second Story

    @override void initState() { super.initState();

    initStoryPages(widget.index);
    

    }

    initStoryPages(int index) { index = index; for (int i = 0; i < widget.status[index].photoUrl.length; i++) { storyItems.add(StoryItem.pageImage( url: widget.status[index].photoUrl[i], controller: controller)); } }

    StoryView( controller: controller, storyItems: storyItems, onComplete: () { print('current state ${controller.playbackNotifier.value}'); // here it is printed as paused

                    setState(() {
                      index += 1;
                   
                      if (storyItems.isNotEmpty) {
                        storyItems.clear();
                      }
                      if (index < widget.status.length) {
                        initStoryPages(index);
                      }
                      if (index >= widget.status.length) {
                        Navigator.pop(context);
                      }
                    });
    
                  
                  },
    

    First story is loaded from initstate and then second story from status list index in oncomplete method, after loading it gets paused, i tried controller.play(), nothing happens , if i click on the image then story resumes. please help me how to resolve this issue.

    opened by vasanthbalaji88 0
  • iOS Failed to load video

    iOS Failed to load video

    Hello, I have this exception when i play video on iOS only [VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(VideoError, Failed to load video: Cannot Open, null, null)

    I init the item :

     StoryItem.pageVideo(
                *my_url*,
                controller: storyController,
              )
    

    When I play the same video with the video_player it still works correctly VideoPlayerController.network(**myurl**);

    I saw some parts that it could come from the header of the video returned from the server. Here is my header :

    Accept-Ranges: bytes
    Content-Length: 37622786
    Content-Type: application/octet-stream
    Date: Sat, 17 Sep 2022 13:01:41 GMT
    ETag: "cc865cd42a0f3b1a29ed59d2d5c684f3"
    Last-Modified: Sat, 06 Aug 2022 14:21:42 GMT
    Server: AmazonS3
    x-amz-id-2: ***ID***
    x-amz-request-id: ***ID***
    
    

    This is a known issue ?

    opened by Knackynouille 1
Owner
Degreat
I can draw. I can't code. ๐Ÿ˜•
Degreat
A mobile cinema App for customers to book a sit and view upcoming shows

?? ?? Booking Theater โœจ Requirements Any Operating System (ie. MacOS X, Linux, Windows) Any IDE with Flutter SDK installed (ie. IntelliJ, Android Stud

Olajire Abdullah 3 Nov 17, 2022
Arisstaggeredgridview - Staggered Grid View For Flutter

Flutter - StaggeredGridView We complete the design challenge by integrating a St

Behruz Hurramov 2 Jan 9, 2022
Simple reactive animations in your Flutter apps.

just.motion Flutter package to create organic motion transitions. Why? The Motion Value stateless hot reload status notifier Ease Motion Spring Motion

Roi Peker 49 Nov 14, 2022
A light weight package for flutter apps, that easily shows a splash screen with a nice fade animation.

Animated Splash Screen Using the package Get the library environment: sdk: ">=2.1.0 <3.0.0" Add dependency in pubspec.yaml dependencies: animated_

Mohammad Fayaz 112 Oct 6, 2022
A customizable and easy to use UI widgets to help develop apps faster

Lenore UI Beautiful, customizable and easy to use UI widgets to help me (or maybe you) develop my (or maybe your) apps faster. This is my personal pac

Lenore 3 Nov 4, 2022
Stories like in Instagram, each story can include multiple images and videos. Package supports video, titles, preliminary caching.

flutter_instagram_stories A Flutter package for displaying stories just like Whatsapp & Instagram. Built-in groups (multiple stories with one icon), c

Alex Awaik 125 Dec 9, 2022
camilo velandia 69 Dec 30, 2022
Slibro is a full-fledged story writing and publishing platform that supports short and long format stories

Slibro is a full-fledged story writing and publishing platform that supports short and long format stories. Flutter, Appwrite, and Rapyd is use

Souvik Biswas 7 Dec 8, 2022
Flutter Story App UI

Flutter Story App UI Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is your fi

Abdi Hamid 927 Dec 24, 2022
Story app UI in Flutter!

Stories App UI A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started i

Flutter Boy 9 Dec 6, 2022
News App developed with Flutter featuring beautiful UI, category-based news, story for faster news reading, inbuilt article viewer, share feature, and more.

Ariel News App developed with Flutter featuring beautiful UI, category-based news, story for faster news reading, inbuilt article viewer, share featur

Hash Studios 30 Nov 9, 2022
DostiPak - Dating app to make connection between people and start new love story to lovers

Dosti Pak Dating app to make connection between people and start new love story

ABDULKARIM ALBAIK 6 Oct 2, 2022
An advanced story viewer for Flutter. Quite easy & Quite advanced

AdvStory ?? Quite simple & Quite advanced ?? Advanced Story viewer for Flutter. Supports image, video and custom stories. Full control over stories fo

ErtuฤŸrul Yakฤฑn 21 Nov 18, 2022
๐Ÿฆ‹Beautiful flutter app for downloading Instagram stories ๐Ÿš€

NOTE: No longer maintained Instory ?? ?? Beautiful flutter app for downloading Instagram stories ?? Demo video Dependencies used video_player http dio

Sarath 204 Dec 16, 2022
story_designer is created to help developers out there who are looking for implementing Instagram like stories editor.

story_designer A package for creating instagram like story, you can use this package to edit images and make it story ready by adding other contents o

Gulshan Yadav 19 Nov 2, 2022
Flutter page widget that is dismissed by swipe gestures, with Hero style animations, Inspired by Facebook and Instagram stories.

dismissible_page ?? ?? Creates page that is dismissed by swipe gestures, with Hero style animations, Inspired by FB, IG stories. Live Demo Contents Su

Tornike 76 Dec 22, 2022
A simple way to share Instagram stories as an embedded feature within the Flutter application

Loopi Share A simple way to share Instagram stories as an embedded feature within the Flutter application. Introduction Words on both platforms Androi

Loopi 5 Sep 24, 2022
Image Editor Plugin with simple, easy support for image editing using Paints, Text, Filters, Emoji and Sticker like stories.

ImageEditorPro Image Editor Plugin with simple, easy support for image editing using Paints, Text, Filters, Emoji and Sticker like stories. To start w

Zeeshan 206 Dec 2, 2022
Image editing using Paints, Text, Filters, Emoji and Sticker like stories, Built With Flutter

ImageEditorPro Image Editor Plugin with simple, easy support for image editing u

Kaushikkumar Godhani 4 Nov 13, 2022
Social app has a real time connection with firebase , contains posts, chats, stories, friends

##SocialKom (Social App) #####First Notice this: you need to link the app with fire base by: 1- adding google-services.json for android 2- adding goog

Mina  Faried 24 Oct 8, 2022