• Stars
    star
    1,901
  • Rank 24,411 (Top 0.5 %)
  • Language
    Dart
  • License
    MIT License
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“Έ 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.

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 (what?).

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.

Gallery

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

More Repositories

1

audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
Dart
1,973
star
2

dashbook

Development tools to help you building UI on Flutter
Dart
391
star
3

trex-flame

Flutter port of the famous Trex game
Dart
354
star
4

bitmap

A Flutter package for manipulating bitmaps
Dart
175
star
5

flame_and_watch

Flame and watch is a fantasy console/engine made in Flutter and Flame, inspired by olds Nintendo's consoles.
Dart
101
star
6

bgug

Break Guns Using Gems is a fast paced side-scrolling platformer with innovative controls and a gun-related twist.
Dart
93
star
7

vscode-dart-import

A simple plugin for VSCode to change all Dart/Flutter imports to relative format.
TypeScript
64
star
8

daylight

Get the sunset and sunrise times for a geolocation without having to access any api.
Dart
58
star
9

fast_noise

Port of the fast noise algorithms
Dart
44
star
10

bob_box

Simple Flame Game to function as a tutorial
Dart
42
star
11

melos-action

An environment with Melos activated for use in GitHub Actions.
36
star
12

ocarina

Flutter plugin to play local audio files
Swift
32
star
13

cached_value

A simple way to cache values that result from rather expensive operations.
Dart
29
star
14

rogue_shooter

Scrolling shooter game
Dart
22
star
15

heeve

Game for GitHub's GameOff 2021
Dart
20
star
16

ordered_set

A simple implementation for an ordered set
Dart
19
star
17

mini_sprite

A simple sprite format for building 1bit styled graphics.
Dart
16
star
18

canvas_test

A flutter package with classes to help testing applications using the canvas
Dart
15
star
19

flutter_gapless_audio_loop

Flutter package to enable playing gapless audio loops
Dart
15
star
20

super_flutter_maker

Super Flutter Maker is an online community where people train their knowledge about the Flutter Widgets, by solving puzzles using the widgets themselves.
Dart
12
star
21

gravitational_waves

This is a simple homage to Gravity Square, an old inifinity runner discountinued by Kongregate.
Dart
10
star
22

deposit

Dart
10
star
23

flame_centipede

Centipede game made in Flame
Dart
10
star
24

spec-action

An environment with Spec activated for use in GitHub Actions.
Shell
9
star
25

padracing

This is a sample game for DartPad
Dart
9
star
26

dartdoc_json

Dart
8
star
27

flutter-itchio-desktop

Build your Flutter Application and deploy it to Itch.io
6
star
28

pocket-dungeons

A simple dungeon crawler turn-based rogue-like for desktop.
Dart
6
star
29

snake-chef

Dart
5
star
30

flame-examples

Repository to store the sources of the Flame videos
Dart
4
star
31

qri

JavaScript
4
star
32

ghost-vs-wonderland

Dart
3
star
33

fireslime.github.io

Fireslime website
HTML
3
star
34

fireslime-discord-bot

Fireslime's discord bot
JavaScript
3
star
35

SpritesheetMapper

Simple application to help create animations using tileset images
JavaScript
3
star
36

ember_bot

The BlueFire Discord Bot
Dart
3
star
37

blue-fire-site

Source code for the Blue Fire website
HTML
3
star
38

homura

Homura is a simple application to create 2d animations, and is a very early work in progress
JavaScript
2
star
39

firescore

Dart
1
star
40

airplane-resource-pack

repository for some prototyping assets for a scrolling shooter
1
star
41

mini_hub

Repository with assets for the Mini Sprite Hub
1
star