MIT License

项目介绍

bluefireteam/photo_view 是一个托管在 GitHub 上的开源项目,主要使用 Dart 编写,采用 MIT License 许可证,目前获得 2.0k 个 Star、584 次 Fork。

仓库全名
bluefireteam/photo_view
开源许可证
MIT License
Star 数
2.0k
Fork 数
584
未关闭 Issue
120

README 摘要

Flutter Photo View A simple zoomable image/content widget for Flutter. PhotoView enables images to become able to zoom and pan with user gestures such as pinch, rotate and drag. It also can show any widget instead of an image, such as Container, Text or a SVG. Even though being super simple to use, PhotoView is extremely customizable though its options and the controllers. Installation Add photoview as a dependency…

完整内容见 GitHub 原始 README 或本页 。

常见问题

photo_view 用什么语言开发?

主要使用 Dart 编写,采用 MIT License 许可证,目前有 2.0k 个 Star。

photo_view 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 photo_view 的源码?

可以直接克隆仓库:git clone https://github.com/bluefireteam/photo_view.git,默认分支为 main;安装与运行步骤见仓库 README。

photo_view 最近还在维护吗?

仓库最近一次更新为 2024年9月4日,当前有 120 个未关闭 Issue;Star 数为 2.0k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
3181
价值分
1369
活跃状态
活跃

语言占比

Dart
Shell

Release

README

Flutter Photo View

Tests status Pub Chat

A simple zoomable image/content widget for Flutter.

PhotoView enables images to become able to zoom and pan with user gestures such as pinch, rotate and drag.

It also can show any widget instead of an image, such as Container, Text or a SVG.

Even though being super simple to use, PhotoView is extremely customizable though its options and the controllers.

Installation

Add photo_view as a dependency in your pubspec.yaml file.

Import Photo View:

import 'package:photo_view/photo_view.dart';

Docs & API

The API Docs some detailed information about how to use PhotoView.

If you want to see it in practice, check the example app that explores most of Photo View’s use cases or download the latest version apk on the releases page

(Very) Basic usage

Given a ImageProvider imageProvider (such as AssetImage or NetworkImage):

@override
Widget build(BuildContext context) {
  return Container(
    child: PhotoView(
      imageProvider: AssetImage("assets/large-image.jpg"),
    )
  );
}

Result:

In action

Read more about the PhotoView widget here.

To show several images and let user change between them, use PhotoViewGallery.

Read more about the gallery here.

import 'package:photo_view/photo_view.dart';
import 'package:photo_view/photo_view_gallery.dart';
// ...


@override
Widget build(BuildContext context) {
  return Container(
    child: PhotoViewGallery.builder(
      scrollPhysics: const BouncingScrollPhysics(),
      builder: (BuildContext context, int index) {
        return PhotoViewGalleryPageOptions(
          imageProvider: AssetImage(widget.galleryItems[index].image),
          initialScale: PhotoViewComputedScale.contained * 0.8,
          heroAttributes: PhotoViewHeroAttributes(tag: galleryItems[index].id),
        );
      },
      itemCount: galleryItems.length,
      loadingBuilder: (context, event) => Center(
        child: Container(
          width: 20.0,
          height: 20.0,
          child: CircularProgressIndicator(
            value: event == null
                ? 0
                : event.cumulativeBytesLoaded / event.expectedTotalBytes,
          ),
        ),
      ),
      backgroundDecoration: widget.backgroundDecoration,
      pageController: widget.pageController,
      onPageChanged: onPageChanged,
    )
  );
}

Gallery sample in the example app:

In action

See the code here.

Usage with controllers

When you need to interact with PhotoView’s internal state values, PhotoViewController and PhotoViewScaleStateController are the way to.

Controllers, when specified to PhotoView widget, enables the author(you) to listen for state updates through a Stream and change those values externally.

Read more about controllers here.

In the example app, we can see what can be achieved with controllers:

In action

More screenshots

Custom background,
small image
and custom alignment
Limited scale Hero animation
In action In action In action
Part of the screen Custom child
In action In action

Support us

You can support us by becoming a patron on Patreon, any support is much appreciated.

Patreon

评论

暂无评论