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

pinch_zoom_release_unzoom 표지
패키지 상세v2.0.0

pinch_zoom_release_unzoom

핀치로 줌 인/아웃할 수 있는 위젯으로, 핀치 동작이 끝나면 원래 크기로 돌아갑니다. 인스타그램에서 사진을 확대하는 방식과 매우 유사합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
4.2천
좋아요
65
Pub 점수
160

패키지 설치

flutter pub add pinch_zoom_release_unzoom

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

핀치로 확대 기능을 가능하게 하는 플러터 위젯으로, 제스처가 끝난 후 자동으로 원래 크기로 돌아가 인스타그램의 이미지 줌 동작을 모방합니다. 이미지나 콘텐츠가 늘어진 상태로 유지되어서는 안 되는 경우에 적합한 부드럽고 일시적인 확대 효과를 제공합니다. Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼을 지원하여 크로스플랫폼 애플리케이션에 매우 유연합니다. 가볍고 최소한의 구성으로 쉽게 통합할 수 있습니다.

사용 사례

  • 임시 확대 기능을 사용한 이미지 보기
  • 동적 스케일링을 갖춘 인터랙티브 UI 요소
  • 크로스플랫폼 기반의 제스처 기반 콘텐츠 탐색
  • 사진 갤러리에서 사용자 경험 향상
  • 지속적인 스케일링 없이 간단한 줌 효과

주요 기능

  • 핀치 후 원래 크기로 자동 복귀
  • 확대 및 축소 중 부드러운 애니메이션
  • 모든 주요 Flutter 플랫폼을 지원합니다
  • 최소한의 설정 필요
  • 직관적인 제스처 인식

적합한 대상

  • 이미지 중심 앱을 개발하는 개발자
  • 임시 줌 상호작용이 필요한 앱
  • 인스타그램과 유사한 제스처를 목표로 하는 프로젝트
  • 직관적인 터치 피드백을 원하는 UI 디자이너
  • 제스처가 필요한 크로스플랫폼 애플리케이션

고려 사항

  • 지속적인 줌 상태에 적합하지 않습니다
  • 줌 동작에 대한 사용자 정의 제한
  • 복잡한 레이아웃 처리를 위해 추가 조치가 필요할 수 있습니다
  • 정적 또는 스크롤되지 않는 콘텐츠와 함께 사용하는 것이 가장 좋습니다
  • 큰 또는 고해상도 이미지에서는 성능이 달라질 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

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

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.