ZM009 / control_pad_plus

A version of control_pad that supports null safety.
https://pub.dev/packages/control_pad_plus
GNU General Public License v3.0
2 stars 2 forks source link

Exception caught by gesture #1

Open JoergSH opened 1 year ago

JoergSH commented 1 year ago

When I touch the pad Ball doesn't move I get following Problem:

D/ViewRootImpl@9bf0ff2[MainActivity](25051): ViewPostIme pointer 0

======== Exception caught by gesture ===============================================================
The following _TypeError was thrown while handling a gesture:
Null check operator used on a null value

When the exception was thrown, this was the stack: 
#0      JoystickView.build.<anonymous closure>.<anonymous closure> (package:control_pad_plus/views/joystick_view.dart:111:60)
#1      DragGestureRecognizer._checkStart.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:497:53)
#2      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:275:24)
#3      DragGestureRecognizer._checkStart (package:flutter/src/gestures/monodrag.dart:497:7)
#4      DragGestureRecognizer.acceptGesture (package:flutter/src/gestures/monodrag.dart:420:7)
#5      GestureArenaManager._resolveByDefault (package:flutter/src/gestures/arena.dart:268:25)
#6      GestureArenaManager._tryToResolveArena.<anonymous closure> (package:flutter/src/gestures/arena.dart:248:31)
(elided 2 frames from dart:async)
Handler: "onStart"
Recognizer: PanGestureRecognizer#026c8
  debugOwner: GestureDetector
  start behavior: start
====================================================================================================
D/ViewRootImpl@9bf0ff2[MainActivity](25051): ViewPostIme pointer 1
I/flutter (25051): STOP

What goes wrong? I use latest Android Studio Giraffe | 2022.3.1

OgnjenX commented 1 year ago

I'm experiencing the same issue. Have you found a solution @JoergSH ?

ManodyaRasanjana commented 1 year ago

Not sure if this is a optimal solution, but assigning a value to the "_callbackTimestamp" worked for me. You can find the problematic function at,

control_pad_plus/lib/views/joystick_view.dart >> GestureDetector(onPanStart)

(Above path is only for joystick. Since I was only using the joystick widget, do not have an idea about other views.)

Then edit the "onPanStart:" function as follows.

onPanStart: (details) {
              // add this block
              if (_callbackTimestamp == null) {
                _callbackTimestamp = DateTime.now();
              }
              // ends here
              _callbackTimestamp = _processGesture(actualSize, actualSize / 2,
                  details.localPosition, _callbackTimestamp!);
              setState(() => lastPosition = details.localPosition);
            },