Orientação gerada a partir de informações públicas. Apenas para referência.
Um pacote Flutter que permite aos desenvolvedores exibir histórias com vídeos, imagens e texto em um formato deslizante e de tela cheia semelhante ao Instagram e WhatsApp. Ele suporta transições suaves, progressão automática e elementos de interface personalizáveis. O pacote foi projetado para simplicidade e desempenho em plataformas Android, iOS e macOS. Integra-se perfeitamente em aplicativos Flutter existentes com configuração mínima. Ideal para aplicativos de redes sociais, plataformas de compartilhamento de conteúdo ou qualquer app que exija uma experiência semelhante a histórias.
Casos de uso
Aplicativos de mídia social
recursos de compartilhamento de conteúdo
Fluxos de onboarding de usuário
Tutoriais interativos
Campanhas de marketing
Principais recursos
Navegação de história deslizável
Suporte para vídeo, imagem e texto
Avanço automático entre histórias
Componentes de interface personalizáveis
Compatibilidade multiplataforma
Indicado para
Desenvolvedores construindo recursos sociais
Aplicativos que precisam de narrativa interativa
Projetos com conteúdo multimídia
Aplicações com foco em dispositivos móveis
Prototipagem rápida de interfaces de histórias
Considerações
Requer gerenciamento adequado de ativos
Opções limitadas de personalização embutidas
Pode ser necessário estilização adicional para designs complexos
Depende do renderização específica da plataforma
Não otimizado para sequências muito longas de histórias
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
FlutterStoryPresenter
This Flutter package makes it easy to create story and news views like popular social media apps with just a few lines of code! 📱✨ It's loaded with features for customizing and managing stories, perfect for showcasing stories inside your awesome app.
For a detailed view and more examples, check out example/main.dart.
Use FlutterStoryPresenter to display stories on any screen. It accepts a list of StoryItem, each containing URLs for displaying images, videos, and web pages.
FlutterStoryPresenter(
controller : FlutterStoryController(),
items: [
/// For Image Story ItemStoryItem(
url:'https://picsum.photos/1000/1000',
type: StoryItemType.image,
),
/// For Video Story ItemStoryItem(
url:'https://videos.pexels.com/video-files/7297870/7297870-hd_1080_1920_30fps.mp4',
type: StoryItemType.video,
),
/// For Text Story ItemStoryItem(
url:'We won this tournament ... Many more to go',
type: StoryItemType.text,
),
/// For Web Story ItemStoryItem(
url:'https://devkrest.com/',
type: StoryItemType.web,
),
/// For Custom Story ItemStoryItem(
customWidget: YourOwnBakedStoryWidget(),
type: StoryItemType.custom,
),
]
)
FlutterStoryPresenter Properties
Here are some of the properties you may have look for further customisations & callbacks.
/// List of StoryItem objects to display in the story view.finalList<StoryItem> items;
/// Controller for managing the current playing media.finalFlutterStoryController? flutterStoryController;
/// Callback function triggered whenever the story changes or the user navigates to the previous/next story.finalOnStoryChanged? onStoryChanged;
/// Callback function triggered when all items in the list have been played.finalOnCompleted? onCompleted;
/// Callback function triggered when the user taps on the left half of the screen./// Returns a Future<bool> - if true, the story will navigate to the previous item; if false, navigation is blocked./// If not provided, tapping left will always navigate to the previous story.finalOnLeftTap? onLeftTap;
/// Callback function triggered when the user taps on the right half of the screen./// Returns a Future<bool> - if true, the story will navigate to the next item; if false, navigation is blocked./// If not provided, tapping right will always navigate to the next story.finalOnRightTap? onRightTap;
/// Callback function triggered when user drag downs the storyview.finalOnSlideDown? onSlideDown;
/// Callback function triggered when user starts drag downs the storyview.finalOnSlideStart? onSlideStart;
/// Indicates whether the story view should restart from the beginning after all items have been played.finalbool restartOnCompleted;
/// Index to start playing the story from initially.finalint initialIndex;
/// Configuration and styling options for the story view indicator.finalStoryViewIndicatorConfig? storyViewIndicatorConfig;
/// Callback function to retrieve the VideoPlayerController when it is initialized and ready to play.finalOnVideoLoad? onVideoLoad;
/// Widget to display user profile or other details at the top of the screen.finalWidget? headerWidget;
/// Widget to display text field or other content at the bottom of the screen.finalWidget? footerWidget;
Using FlutterStoryController
FlutterStoryController is a controller class designed to manage the current story displayed on FlutterStoryPresenter. It includes various methods such as play(), pause(), jumpTo(), next(), previous(), mute(), and unMute(), allowing you to control the existing StoryItem.
final storyController = FlutterStoryController();
FlutterStoryPresenter(
controller : storyController,
items: [
/// Story Item goes here
]
)
...
/// Somewhere in your code
storyController.pause();
storyController.play();
storyController.next();
storyController.previous();
storyController.jumpTo(2);
storyController.mute();
storyController.unMute();
Using StoryItem
The StoryItem class is used to define the individual items displayed in a FlutterStoryPresenter. Each StoryItem can represent an image, video, text, web content, or a custom widget.
url: The URL, file path, or web URL of the story item. Required unless storyItemType is custom.
storyItemType: The type of story item. Required. It can be an image, video, text, web content, or custom.
thumbnail: A widget to display as a thumbnail.
isMuteByDefault: A boolean indicating whether the video should be muted by default. Applicable when storyItemType is video.
duration: The duration for displaying the widget. Defaults to 3 seconds.
storyItemSource: The source type of the story item. Defaults to StoryItemSource.network.
videoConfig: Configuration for video stories.
errorWidget: A widget to display when an error occurs while loading the view.
imageConfig: Configuration for image stories.
textConfig: Configuration for text stories.
webConfig: Configuration for web stories.
customWidget: A custom widget to display fully instead of any other view. Required when storyItemType is custom.
Example
StoryItem(
url: 'https://example.com/image.jpg',
storyItemType: StoryItemType.image,
storyItemSource: StoryItemSource.network,
duration: Duration(seconds: 5),
thumbnail: Image.network('https://example.com/thumbnail.jpg'),
imageConfig: StoryViewImageConfig(
fit: BoxFit.cover,
height: 300,
width: 300,
progressIndicatorBuilder: (_,_,loadProgress){
returnYourImageLoaderWidget();
}
),
)
StoryItem(
url: 'https://example.com/video.mp4',
storyItemType: StoryItemType.video,
isMuteByDefault: true,
storyItemSource: StoryItemSource.network,
duration: Duration(seconds: 10),
videoConfig: StoryViewVideoConfig(
cacheVideo: true,
fit: BoxFit.cover,
height: 500,
width: 500,
loadingWidget: MyVideoLoadingWidget(),
/// If you opt to cache video, // it will store to user device and then played, // if already cached, will play without buffer // from next time
cacheVideo: false,
useVideoAspectRatio: false,
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true,),
),
)
StoryItem(
storyItemType: StoryItemType.custom,
customWidget: MyCustomWidget(),
)
Full Example
This is the full example demonstrating the usage of FlutterStoryPresenter. For more insights and detailed reference, refer to the official documentation.