title: Flutter Camera pinch zoom
body: <p>I'm trying to create a camera app in Flutter but I keep bumping into zoom issues.
  I managed to get the zoom code working via buttons, but when I try to replace those buttons with a GestureDetector, nothing happens.</p>
  <p>Below is the camera page. I tried checking if my gestureDetector gets called somewhere by adding a debugLog, but this prints nothing so I think the issue is with calling the detector and not necessarily the code inside the detector</p>
  <pre class="lang-dart prettyprint-override"><code>
  class CameraPreviewPage extends StatefulWidget {
    final CameraDescription camera;
  
    CameraPreviewPage({required this.camera});
  
    @override
    _CameraPreviewPageState createState() =&gt; _CameraPreviewPageState();
  }
  
  class _CameraPreviewPageState extends State&lt;CameraPreviewPage&gt; {
    late CameraController _cameraController;
    late Future&lt;void&gt; _initializeCameraControllerFuture;
    double zoom = 1.0;
    double _scaleFactor = 1.0;
  
    @override
    void initState() {
      super.initState();
  
      _cameraController =
          CameraController(widget.camera, ResolutionPreset.ultraHigh);
  
      _initializeCameraControllerFuture = _cameraController.initialize();
    }
  
    @override
    Widget build(BuildContext context) {
      return Stack(
        children: &lt;Widget&gt;[
         FutureBuilder(
              future: _initializeCameraControllerFuture,
              builder: (context, snapshot) {
                //The gestureDetector doesn't work
                if (snapshot.connectionState == ConnectionState.done) {
                  return
                    GestureDetector(
                      behavior: HitTestBehavior.translucent,
                      onScaleStart: (details) {
                         zoom = _scaleFactor;
                      },
                      onScaleUpdate: (details) {
                         _scaleFactor = zoom * details.scale;
                         _cameraController.setZoomLevel(_scaleFactor);
                         debugPrint('Gesture updated');
                      },
                      child:CameraPreview(_cameraController));
                } else {
                  return Center(child: CircularProgressIndicator());
                }
              },
            ),
  
          SafeArea(
              child: Scaffold(
            backgroundColor: Colors.transparent,
            floatingActionButton:
                Column(mainAxisSize: MainAxisSize.min, children: &lt;Widget&gt;[
              FloatingActionButton(
                heroTag: &quot;FABZoomIn&quot;,
                child: Icon(
                  Icons.zoom_in,
                  color: Colors.white,
                ),
                onPressed: () {
                  if (zoom &lt; 8) {
                    zoom = zoom + 1;
                  }
                  _cameraController.setZoomLevel(zoom);
                },
                backgroundColor: Colors.cyan,
              ),
              SizedBox(
                height: 10,
              ),
              FloatingActionButton(
                heroTag: &quot;FABZoomOut&quot;,
                child: Icon(
                  Icons.zoom_out,
                  color: Colors.white,
                ),
                onPressed: () {
                  if (zoom &gt; 1) {
                    zoom = zoom - 1;
                  }
                  _cameraController.setZoomLevel(zoom);
                },
                backgroundColor: Colors.red,
              ),
              SizedBox(
                height: 10,
              ),
              FloatingActionButton(
                  heroTag: &quot;FABCamera&quot;,
                  child: Icon(Icons.camera, color: Colors.white),
                  backgroundColor: Colors.green,
                  onPressed: () {
                    _takePicture(context);
                  })
            ]),
          ))
        ],
      );
    }
  
    @override
    void dispose() {
      _cameraController.dispose();
      super.dispose();
    }
  }
  </code></pre>
  <p>EDIT: I've also tried using onTap to see if this gives me any more insights in what could be going wrong, but onTap also doesn't get registered.</p>