Why my Flutter BottomSheet gives me a GestureDetector error?

1,115

As commented, just put enableDrag: false, and it will work.

Share:
1,115
Steven Dz
Author by

Steven Dz

Updated on December 20, 2022

Comments

  • Steven Dz
    Steven Dz over 1 year

    I have a problem with this BottomSheet, it works fine but as soon as I tap on it, I will get an error...

    bottomSheet: showBottomSheet
            ? BottomSheet(
                enableDrag: true,
                onClosing: () {},
                builder: (ctx) => Container(
                  height: 200,
                  width: double.infinity,
                  color: Colors.red,
                ),
              )
    

    Why I am getting this error?

    ════════ Exception caught by gesture ═══════════════════════════════════════════
    The following NoSuchMethodError was thrown while handling a gesture:
    The getter 'status' was called on null.
    Receiver: null
    Tried calling: status
    
    When the exception was thrown, this was the stack
    #0      Object.noSuchMethod  (dart:core-patch/object_patch.dart:53:5)
    #1      _BottomSheetState._dismissUnderway 
    package:flutter/…/material/bottom_sheet.dart:187
    #2      _BottomSheetState._handleDragEnd 
    package:flutter/…/material/bottom_sheet.dart:204
    #3      DragGestureRecognizer._checkEnd.<anonymous closure> 
    package:flutter/…/gestures/monodrag.dart:439
    #4      GestureRecognizer.invokeCallback 
    package:flutter/…/gestures/recognizer.dart:182
    ...
    Handler: "onEnd"
    Recognizer: VerticalDragGestureRecognizer#22607
        debugOwner: GestureDetector
        start behavior: start
    

    What do I need to add? I guess I need to add an OnDragEnd function? Please help, thanks