为什么我的Flutter BottomSheet给我一个GestureDetector错误?

问题描述 投票:0回答:1

我有一个问题,这个BottomSheet,它工作得很好,但只要我点击它,我就会得到一个错误......

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

为什么会出现这个错误?

════════ 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

我需要添加什么?我想我需要添加一个OnDragEnd功能? 请帮助,谢谢。

flutter bottom-sheet gesturedetector
1个回答
0
投票

如上所述,只需将 enableDrag: false, 而且会有效果。

© www.soinside.com 2019 - 2024. All rights reserved.