StoryItem.pageImage constructor

StoryItem.pageImage({
  1. required String url,
  2. required StoryController controller,
  3. Key? key,
  4. BoxFit imageFit = BoxFit.fitWidth,
  5. Text? caption,
  6. bool shown = false,
  7. Map<String, dynamic>? requestHeaders,
  8. Widget? loadingWidget,
  9. Widget? errorWidget,
  10. EdgeInsetsGeometry? captionOuterPadding,
  11. Duration? duration,
})

Factory constructor for page images. controller should be same instance as one passed to the StoryView

Implementation

factory StoryItem.pageImage({
  required String url,
  required StoryController controller,
  Key? key,
  BoxFit imageFit = BoxFit.fitWidth,
  Text? caption,
  bool shown = false,
  Map<String, dynamic>? requestHeaders,
  Widget? loadingWidget,
  Widget? errorWidget,
  EdgeInsetsGeometry? captionOuterPadding,
  Duration? duration,
}) {
  return StoryItem(
    Container(
      key: key,
      color: Colors.black,
      child: Stack(
        children: <Widget>[
          StoryImage.url(
            url,
            controller: controller,
            fit: imageFit,
            requestHeaders: requestHeaders,
            loadingWidget: loadingWidget,
            errorWidget: errorWidget,
          ),
          SafeArea(
            child: Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                width: double.infinity,
                margin: EdgeInsets.only(
                  bottom: 24,
                ),
                padding: captionOuterPadding?? EdgeInsets.symmetric(
                  horizontal: 24,
                  vertical: 8,
                ),
                color: caption != null ? Colors.black54 : Colors.transparent,
                child: caption?? const SizedBox.shrink(),
              ),
            ),
          )
        ],
      ),
    ),
    shown: shown,
    duration: duration ?? Duration(seconds: 3),
  );
}