Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Without twoTouchOnly set to true in Column, CastError appears #6

Closed
LevinGermann opened this issue Aug 5, 2021 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@LevinGermann
Copy link

LevinGermann commented Aug 5, 2021

Describe the bug
I have the ZoomOverlay used in a Column widget, and when I don't set the twoTouchOnly property to true, the widget glitches quickly, bounces back to the original location and produces an error:

I/flutter (23218): ══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (23218): The following _CastError was thrown while notifying listeners for AnimationController:
I/flutter (23218): Null check operator used on a null value
I/flutter (23218):
I/flutter (23218): When the exception was thrown, this was the stack:
I/flutter (23218): #0 _ZoomOverlayState.initState. (package:zoom_pinch_overlay/zoom_pinch_overlay.dart:92:36)
I/flutter (23218): #1 AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:136:19)
I/flutter (23218): #2 AnimationController.value= (package:flutter/src/animation/animation_controller.dart:366:5)
I/flutter (23218): #3 AnimationController.reset (package:flutter/src/animation/animation_controller.dart:385:5)
I/flutter (23218): #4 _ZoomOverlayState.onScaleEnd (package:zoom_pinch_overlay/zoom_pinch_overlay.dart:176:22)
I/flutter (23218): #5 ScaleGestureRecognizer._reconfigure. (package:flutter/src/gestures/scale.dart:465:53)
I/flutter (23218): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
I/flutter (23218): #7 ScaleGestureRecognizer._reconfigure (package:flutter/src/gestures/scale.dart:465:11)
I/flutter (23218): #8 ScaleGestureRecognizer.handleEvent (package:flutter/src/gestures/scale.dart:388:36)
I/flutter (23218): #9 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:93:12)
I/flutter (23218): #10 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:138:9)
I/flutter (23218): #11 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:397:8)
I/flutter (23218): #12 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:136:18)
I/flutter (23218): #13 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:122:7)
I/flutter (23218): #14 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:439:19)
I/flutter (23218): #15 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419:22)
I/flutter (23218): #16 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:287:11)
I/flutter (23218): #17 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
I/flutter (23218): #18 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
I/flutter (23218): #19 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
I/flutter (23218): #20 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
I/flutter (23218): #24 _invoke1 (dart:ui/hooks.dart:182:10)
I/flutter (23218): #25 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:282:7)
I/flutter (23218): #26 _dispatchPointerDataPacket (dart:ui/hooks.dart:96:31)
I/flutter (23218): (elided 3 frames from dart:async)
I/flutter (23218):
I/flutter (23218): The AnimationController notifying listeners was:
I/flutter (23218): AnimationController#e9df8(⏮ 0.000; paused)
I/flutter (23218): ════════════════════════════════════════════════════════════════════════════════════════════════════

A workaround is to set this field to true; but the same error will appear if you then try to use 3 fingers instead of just 2.

To Reproduce

Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.only(top: 16.0),
          child: Center(
            child: AspectRatio(
              aspectRatio: kImageAspectRatio,
              child: ZoomOverlay(
                minScale: 0.5,
                maxScale: 3.0,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(6),
                  child: CachedNetworkImage(
                    imageUrl: imageUrl!,
                    fadeInCurve: Curves.easeInOutSine,
                    placeholder: (context, _) =>
                        const ImageLoadingPlaceholder(),
                  ),
                ),
              ),
            ),
          ),
        ),
        caption,
      ],
    );

Expected behavior
The widget should zoom without an error, no matter if I set the twoTouchOnly property.

Smartphone (please complete the following information):

  • Flutter (Channel stable, 2.2.3, on macOS 11.5 20G71 darwin-arm)
  • zoom_pinch_overlay: 1.1.2
  • Device: Samsung S21
  • OS: Android 11
@LevinGermann LevinGermann added the bug Something isn't working label Aug 5, 2021
@pishguy
Copy link

pishguy commented Dec 2, 2021

+1

@Mayb3Nots
Copy link
Owner

I have fixed the Null assertion error. However for your glitching problem you just have to make the ZoomOverlay above the AspectRatio like this:

Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.only(top: 16.0),
          child: Center(
            child: ZoomOverlay(
              minScale: 0.5,
              maxScale: 3.0,
              child: AspectRatio(
                aspectRatio: kImageAspectRatio,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(6),
                  child: CachedNetworkImage(
                    imageUrl: imageUrl!,
                    fadeInCurve: Curves.easeInOutSine,
                    placeholder: (context, _) =>
                        const ImageLoadingPlaceholder(),
                  ),
                ),
              ),
            ),
          ),
        ),
        caption,
      ],
    );

Let me know if that fixes you problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants