StoryItem.inlineProviderImage constructor

StoryItem.inlineProviderImage(
  1. ImageProvider<Object> image, {
  2. Key? key,
  3. Text? caption,
  4. bool shown = false,
  5. bool roundedTop = true,
  6. bool roundedBottom = false,
  7. Duration? duration,
})

Shorthand for creating an inline story item from an image provider such as AssetImage or NetworkImage. However, the story continues to play while the image loads up.

Implementation

factory StoryItem.inlineProviderImage(
  ImageProvider image, {
  Key? key,
  Text? caption,
  bool shown = false,
  bool roundedTop = true,
  bool roundedBottom = false,
  Duration? duration,
}) {
  return StoryItem(
    Container(
      key: key,
      decoration: BoxDecoration(
          color: Colors.grey[100],
          borderRadius: BorderRadius.vertical(
            top: Radius.circular(roundedTop ? 8 : 0),
            bottom: Radius.circular(roundedBottom ? 8 : 0),
          ),
          image: DecorationImage(
            image: image,
            fit: BoxFit.cover,
          )),
      child: Container(
        margin: EdgeInsets.only(
          bottom: 16,
        ),
        padding: EdgeInsets.symmetric(
          horizontal: 24,
          vertical: 8,
        ),
        child: Align(
          alignment: Alignment.bottomLeft,
          child: Container(
            child: caption == null ? SizedBox() : caption,
            width: double.infinity,
          ),
        ),
      ),
    ),
    shown: shown,
    duration: duration ?? Duration(seconds: 3),
  );
}