Fuad Mostafij
Fuad Mostafij

Reputation: 47

InteractiveViewer not working for child GestureDetector in flutter

I try to build pdf editor, where a feature that is user can draw, i already done this, but when i draw widget can't zoom, i want when user touch in one finger, its draw other wise its zoom

 final Set<int> _activePointers = <int>{}; // To track active pointers (touches)
void _onPanStart(Offset localPosition) {
print("Drawing started at: $localPosition");
}

void _onPanUpdate(Offset localPosition) {
print("Drawing at: $localPosition");
}

@override
Widget build(BuildContext context) {
return Scaffold(
  body: Listener(
    onPointerDown: (PointerEvent event) {
      setState(() {
        _activePointers.add(event.pointer); // Add pointer on down
      });
    },
    onPointerUp: (PointerEvent event) {
      setState(() {
        _activePointers.remove(event.pointer); // Remove pointer on up
      });
    },
    child: InteractiveViewer(
      boundaryMargin: EdgeInsets.all(20),
      minScale: 0.5,
      maxScale: 4.0,
      child: 
    
        Stack(
          children: [
            // Your tappable elements in the stack
          PdfViewer(),
          OtherElement(),

        GestureDetector(
             onPanStart:
                          
            _controller.selectedFileEditOption == 
            FileEditOptions.draw &&
                              events.length == 1?
                              (details) {

                              
              _controller.onPanStart(details: 
                            details.localPosition);

                          }:null,
                          
          onPanUpdate:_controller.selectedFileEditOption == 
                  FileEditOptions.draw &&
                              events.length == 1?
                              (details) {

                              
                  _controller.onPanUpdate(details: 
                         details.localPosition);

                          }:null,

                 child:  

                         RepaintBoundary(
                         key:
                             _drawGlobalKey[index],
                             child: Obx(() {
                              return CustomPaint(
                                foregroundPainter:
                                  DrawingPainter(
                                    drawingPoints:
                                    
         _controller.drawingPoint.toList(),),
                                     child: AspectRatio(
                                     aspectRatio: 
                      pageInfo.size.aspectRatio,
                                    child: Container( 
                   alignment: Alignment.center,
                                                  color: 
              Colors  .transparent,
                                                      ),
                                                    ),);
 
             ],
          

here i want when user tap one finger its detect GestureDetector otherwise its detect InteractiveViewer for zoom but when draw, InteractiveViewer can't detect for zooming

Upvotes: 0

Views: 38

Answers (0)

Related Questions