weImagePreview function

WeImagePreview weImagePreview(
  1. BuildContext context
)

Implementation

WeImagePreview weImagePreview(BuildContext context) {
  final GlobalKey widgetKey = GlobalKey();
  late Function remove;
  Function show(
      {images,
      color = _maskDefaultColor,
      defaultIndex = 0,
      indicators = true}) {
    // 关闭方法
    close() async {
      // 反序播放动画
      await (widgetKey.currentState as PreviewState).reverseAnimation();
      remove();
    }

    remove = createOverlayEntry(
        context: context,
        child: Preview(
            key: widgetKey,
            images: images,
            color: color,
            maskClick: close,
            defaultIndex: defaultIndex,
            indicators: indicators),
        willPopCallback: close);

    return close;
  }

  return show;
}