'package:flutter/src/gestures/tap.dart': Failed assertion: line 201 pos 14: '_down == null && _up == null': is not true

Viewed 540

I am using gesture tap to close the article detail page, when I reopen the article detail page, the app will show this error(the first time open the detail works fine, the second time open the detail will show this error and the detail could not roll up and down):

======== Exception caught by gesture library =======================================================
The following assertion was thrown while dispatching a pointer event:
'package:flutter/src/gestures/tap.dart': Failed assertion: line 201 pos 14: '_down == null && _up == null': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      BaseTapGestureRecognizer.addAllowedPointer (package:flutter/src/gestures/tap.dart:201:14)
#3      GestureRecognizer.addPointer (package:flutter/src/gestures/recognizer.dart:102:7)
#4      RawGestureDetectorState._handlePointerDown (package:flutter/src/widgets/gesture_detector.dart:1204:18)
#5      RenderPointerListener.handleEvent (package:flutter/src/rendering/proxy_box.dart:2821:29)
#6      GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:361:22)
...
Event: PointerDownEvent#6e7c4(position: Offset(191.4, 563.1))
  position: Offset(191.4, 563.1)
Target: RenderPointerListener#946e9 relayoutBoundary=up46
  parentData: <none> (can use size)
  constraints: BoxConstraints(0.0<=w<=363.4, 0.0<=h<=Infinity)
  size: Size(363.4, 458.2)
  behavior: deferToChild
  listeners: down
====================================================================================================

and this is my detail page flutter code:

    return GestureDetector(
          onHorizontalDragStart: _onHorizontalDragStart,
          onHorizontalDragUpdate: _onHorizontalDragUpdate,
          onHorizontalDragEnd: _onHorizontalDragEnd,
          child: Container(
            constraints: BoxConstraints(
              minHeight: MediaQuery.of(context).size.height * 0.9,
            ),
            color: Theme.of(context).scaffoldBackgroundColor,
            child: Padding(
              padding: const EdgeInsets.all(16.0),
              child: buildListView(item, context),
            ),
          ));


 void _onHorizontalDragStart(DragStartDetails details) {
    _initialSwipeOffset = details.globalPosition;
  }

  void _onHorizontalDragUpdate(DragUpdateDetails details) {
    _finalSwipeOffset = details.globalPosition;
  }

  void _onHorizontalDragEnd(DragEndDetails details) {
    if (_initialSwipeOffset != null) {
      final offsetDifference = _initialSwipeOffset!.dx - _finalSwipeOffset!.dx;
      if (offsetDifference < 0) {
        Navigator.pop(context);
      }
    }
  }

I am searching from internet but find no one encount this problem. what should I do to fix this problem?

1 Answers

It looks like you are using a pre-release version of Flutter SDK. I recommend you use Flutter Stable channel and rebuild your project again.

according to Flutter build release channels the stable version is recommended for all production app releases.

Now to know which branch you are currently using. open the terminal and type the following command.

flutter channel

The channel which you are on will be displayed with '*' at the beginning. E.g,

*master
dev
beta
stable

To change to the stable channel, run this command on your terminal.

flutter channel CHANNEL_NAME

For example, change the channel to stable,

flutter channel stable

To ensure that you're on the latest build from this channel, run

flutter upgrade

This is all you need to do.

Related