패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소ivofernandes/pinch_zoom_release_unzoom

핀치 줌 리리즈 언줌

핀치로 확대하고 놓을 때 축소하는 패키지

핀치 줌 리리즈 언줌 프로젝트 이미지
스타
16
포크
9
최근 푸시(UTC)
2026. 6. 2.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

pub package popularity likes pub points

This package helps to create an instagram like zoom picture. With pinch to zoom and release to unzoom

In this video I explained how to use pinch to zoom, in a flutter project

https://youtu.be/V2DglEpynF8

Zoom_demo

Features

Let's your app show zoomable images in an user friendly way.

It's a container of an uncliped interactive viewer that let's the user zoom the image occupying the entire screen. Once you release the screen and stop the pinch interaction the image/widget will come back to it's original size in an smooth animation.

Getting started

Add the dependency to your pubspec.yaml:

pinch_zoom_release_unzoom: ^1.0.1

Usage


PinchZoomReleaseUnzoomWidget(
  child: Image.network(
    'https://storage.googleapis.com/cms-storage-bucket/70760bf1e88b184bb1bc.png'
  ),
)

Additional information

This package also support some extra params that may be useful depending on what are you trying to achieve

PinchZoomReleaseUnzoomWidget(
    child: Image.network('https://storage.googleapis.com/cms-storage-bucket/70760bf1e88b184bb1bc.png'),
    minScale: 0.8,
    maxScale: 4,
    resetDuration: const Duration(milliseconds: 200),
    boundaryMargin: const EdgeInsets.only(bottom: 0),
    clipBehavior: Clip.none,
    useOverlay: true,
    maxOverlayOpacity: 0.5,
    overlayColor: Colors.black,
    fingersRequiredToPinch: 2
)

Making it work well inside a scroll

I made a video explaining how to solve the pinch to zoom inside a scroll:

https://youtu.be/FUuCOdQerpw

The problem with making a pinch working inside a scroll is that the drag of a screen, as a simple gesture that can be done with just one finger, tends to override the more complex scale gesture that needs two fingers to work well, the best way I found to overcome that challenge is to change the physics of the scroll to NeverScrollableScrollPhysics() when the second finger touch the screen, that way the scroll stops to override the scale gesture and it's easy to interact with the interactive viewer.

Another consideration that you will need to have is that to avoid losing frames of the reset animation, you need to delay the setState that will bring the scroll back to the parent widget

So the scroll build will look like this:

  bool blockScroll = false;
ScrollController controller = ScrollController();

@override
Widget build(BuildContext context) {
  return SingleChildScrollView(
      controller: controller,
      physics: blockScroll ? NeverScrollableScrollPhysics() : ScrollPhysics(),

And the PinchWidget will have this two extra parameters:

twoFingersOn: () => setState(() => blockScroll = true),
twoFingersOff: () => Future.delayed(
PinchZoomReleaseUnzoomWidget.defaultResetDuration,
() => setState(() => blockScroll = false),

For a complete widget example check this one:

class TestSimpleScroll extends StatefulWidget {
  const TestSimpleScroll({super.key});

  @override
  State<TestSimpleScroll> createState() => _TestSimpleScrollState();
}

class _TestSimpleScrollState extends State<TestSimpleScroll> {
  bool blockScroll = false;
  ScrollController controller = ScrollController();

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      controller: controller,
      physics: blockScroll ? NeverScrollableScrollPhysics() : ScrollPhysics(),
      child: SizedBox(
        width: MediaQuery.of(context).size.width,
        child: Container(
          padding: const EdgeInsets.all(20),
          child: Column(
            children: [
              SizedBox(
                width: 300,
                height: 250,
                child: PinchZoomReleaseUnzoomWidget(
                  child: Image.network(
                    'https://www.animalfriends.co.uk/siteassets/media/images/article-images/cat-articles/38_afi_article1_caring-for-a-kitten-tips-for-the-first-month.png',
                  ),
                  twoFingersOn: () => setState(() => blockScroll = true),
                  twoFingersOff: () => Future.delayed(
                    PinchZoomReleaseUnzoomWidget.defaultResetDuration,
                        () => setState(() => blockScroll = false),
                  ),
                ),
              ),
              const SizedBox(
                height: 5000,
              )
            ],
          ),
        ),
      ),
    );
  }
}

Simulator test

To test in a simulator add a fingersRequiredToPinch to pinch with a -1 to disable the requirement of two fingers to start an interaction

PinchZoomReleaseUnzoomWidget(
    child: Image.network('https://storage.googleapis.com/cms-storage-bucket/70760bf1e88b184bb1bc.png'),
    fingersRequiredToPinch: -1
)

Like us on pub.dev

Package url: https://pub.dev/packages/pinch_zoom_release_unzoom

Ivo Fernandes GitHub avatar
GitHub 작성자

Ivo Fernandes ↗

I'm a Flutter developer with 6 years of experience in Flutter and 16 years of experience in software in general, started in 2008

@devexpertsLisbon, Portugal
언어DartHTMLShellRubySwiftObjective-CKotlin

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개

  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^2.0.1

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗