previewImage function

void previewImage({
  1. int index = 0,
  2. List<String>? menuList,
  3. required BuildContext context,
  4. required List<ChatImageListUtils> imageList,
  5. void onTapMenu(
    1. String data,
    2. int index,
    3. List<String> menuList
    )?,
  6. void customLongPress(
    1. BuildContext context
    )?,
})

预览图片

  • context BuildContext
  • imageList 图片列表
  • index 当前加载展示图片索引
  • menuList 菜单列表
  • onTapMenu 点击菜单选项的回调
  • customLongPress 自定义长按显示菜单回调

Implementation

void previewImage ({
    int index = 0,
    List<String>? menuList,
    required BuildContext context,
    required List<ChatImageListUtils> imageList,
    void Function(String data, int index, List<String> menuList)? onTapMenu,
    void Function(BuildContext context)? customLongPress
}) {
    showModalBottomSheet(
        context: context,
        isScrollControlled: true,
        backgroundColor: Colors.transparent,
        builder: (context) => GestureDetector(
            onTap: () {
                Navigator.pop(context);
            },
            child: _PreviewImageWidget(
                imageList: imageList,
                index: index,
                menuList: menuList,
                onTapMenu: onTapMenu,
                customLongPress: customLongPress
            ),
        )
    );
}