Story Block (Flutter)

Currently, there are eight source types of the story block:

  • Discover

  • Channel

  • Playlist

  • Dynamic Content

  • Hashtag Playlist

  • SKU

  • Single Content

Integration

import 'package:fw_flutter_sdk/fw_flutter_sdk.dart';
import 'package:visibility_detector/visibility_detector.dart';

StoryBlockController? _storyBlockController;

/// discover
StoryBlock(
  height: 400,
  source: StoryBlockSource.discover,
)

/// channel
StoryBlock(
  height: 400,
  source: StoryBlockSource.channel,
  channel: "your encoded channel id",
)

/// playlist
StoryBlock(
  height: 400,
  source: StoryBlockSource.playlist,
  channel: "your encoded channel id",
  playlist: "your encoded playlist id",
)

/// dynamic content
StoryBlock(
  height: 400,
  source: StoryBlockSource.dynamicContent,
  dynamicContentParameters: const {
    '<cohort key>': ['<cohort value1>', '<cohort value2>']
  },
)

/// hashtag playlist
StoryBlock(
  height: 400,
  source: StoryBlockSource.hashtagPlaylist,
  channel: "your encoded channel id",
  hashtagFilterExpression: "<hashtag filter expression>",
)

/// sku
StoryBlock(
  height: 400,
  source: StoryBlockSource.sku,
  channel: "your encoded channel id",
  productIds: ["prodct_id_1", "prodct_id_2"],
)

/// single content
StoryBlock(
  height: 400,
  source: StoryBlockSource.singleContent,
  contentId: "your encoded video or live stream id"
);

Configure corner radius

Story block loading result callback

StoryBlock widget provides onStoryBlockLoadFinished property for setting story block loading result callback.

Story block empty callback

StoryBlock widget provides onStoryBlockEmpty property for setting story block empty callback. The callback is triggered when there are no items in the story block. For example, you could hide the widget when the callback is triggered. The callback is triggered in the following scenarios:

  1. Load successfully but the back end returns an empty list

  2. The load failed and the list is empty

Play or pause story block programmatically

Open fullscreen story block programmatically (Android)

Enable PiP(Picture in Picture)

Set up the iOS project

To enable PiP outside the iOS app, you also need to add "Audio, Airplay, and Picture in Picture" background mode via Signing & Capabilities in your iOS project settings(as shown in the following screenshot). More information about this can be found here: Apple Documentation

Set enablePictureInPicture to true on Dart side

Keep alive when scrolling the widget out of the view box

Generally, if you put the story block widget as the child of ListView, it will be rebuilt when scrolling the widget out of the view box. You could set wantKeepAlive as true to make the story block widget keep alive when scrolling the widget out of the view box.

Player configurations

Please refer to Player configurations (Flutter).

Reference

StoryBlock

Last updated

Was this helpful?