display stories
display stories
story view for apps with stories.
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
display stories
�� 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
andpageimage
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.
)
}
Comments are closed.