AdvStory
AdvStory Docs
Search
K
Comment on page

Predefined Content Types

AdvStory has three predefined story type. These are,
  • ImageContent
  • VideoContent
  • SimpleCustomContent
ImageContent and VideoContent accept same parameters except duration. Duration can be set for ImageContent but not for VideoContent, it uses video duration to set countdown and indicator animation.
Shared parameters are,
  • url: content resource url.
  • cacheKey: content resource cache key, default is null. When url contains query parameters, this can be set to avoid unnecessary fetchs.
  • requestHeaders: headers to use when sending request to fetch content resource.
  • header: upper section of the content. This header overrides the header provided to story.
  • footer: bottom section of the content. This footer overrides the footer provided to story.
  • timeout: time limit to prepare content.
  • errorBuilder: called when timeout reached to the end but content couldn't be ready to display. Builder function returns a widget and AdvStory shows it instead of loading screen in this case. Useful to show error messages to user, also a timer can set to skip next story in this builder function.
ImageContent(
// Story skip duration
duration: const Duration(seconds: 10),
url: imageUrls[contentIndex % imageUrls.length],
cacheKey: imageUrls[contentIndex % imageUrls.length],
requestHeaders: const {
"Authorization": "Bearer 12345",
},
header: Text('Header widget'),
footer: Text('Footer widget'),
timeout: const Duration(seconds: 2),
errorBuilder: () {
Future.delayed(const Duration(seconds: 1), () => controller.toNextContent());
return Center(
child: Text('We are unable to display this content...'),
);
}
),
VideoContent(
url: imageUrls[contentIndex % imageUrls.length],
cacheKey: imageUrls[contentIndex % imageUrls.length],
requestHeaders: const {
"Authorization": "Bearer 12345",
},
header: Text('Header widget'),
footer: Text('Footer widget'),
// You may want to set the timeout longer, video files are
// larger than images.
timeout: const Duration(seconds: 4),
errorBuilder: () {
Future.delayed(const Duration(seconds: 1), () => controller.toNextContent());
return Center(
child: Text('We are unable to display this content...'),
);
}
),
When duration set to 10 seconds and timeout to 2 seconds, if AdvStory fails to load content within 2 seconds, calls errorBuilder and shows returned widget instead of loading screen. Set a timer to not show error message for 8 seconds and skip to next content after 1-2 sec.

SimpleCustomContent

This type created for contents that use synchronously loaded resources such as text, asset image. Countdown and story progress indicator start immediately when the content starts to display.
SimpleCustomContent accepts these parameters:
  • builder: returns widget.
  • useStoryHeader: when this is set to true, AdvStory places story header to the top of the screen over the content.
  • useStoryFooter: when this is set to true, AdvStory places story footer to the bottom of the screen over the content.
  • duration: story skip duration.
SimpleCustomContent(
builder: (context) {
retun Center(
child: Text('My simple custom content'),
);
},
useStoryHeader: false,
useStoryFooter: false,
duration: const Duration(seconds: 10),
),