Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting this error on hot restarting #19

Open
Kapish26 opened this issue Aug 3, 2022 · 1 comment
Open

Getting this error on hot restarting #19

Kapish26 opened this issue Aug 3, 2022 · 1 comment

Comments

@Kapish26
Copy link

Kapish26 commented Aug 3, 2022

Getting this error on hot restarting!!! Please help

The following _Exception was thrown while handling a gesture:
Exception: Last error is 0

When the exception was thrown, this was the stack: 
#0      SerialPort.open (package:serial_port_win32/src/serial_port.dart:169:11)
#1      _MyHomePageState._getPortsAndOpen (package:demo/main.dart:43:14)
#2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:1005:21)
#3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:198:24)
#4      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:613:11)
#5      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:298:5)
#6      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:269:7)
#7      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
#8      GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:449:20)
#9      GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:425:22)
#10     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:329:11)
#11     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:380:7)
#12     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:344:5)
#13     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:302:7)
#14     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:285:7)
#18     _invoke1 (dart:ui/hooks.dart:170:10)
#19     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:331:7)
#20     _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
(elided 3 frames from dart:async)
Handler: "onTap"
Recognizer: TapGestureRecognizer#774c2
  debugOwner: GestureDetector
  state: ready
  won arena
  finalPosition: Offset(1212.8, 640.8)
  finalLocalPosition: Offset(19.2, 30.4)
  button: 1
  sent tap down
====================================================================================================
@FengChendian
Copy link
Owner

FengChendian commented Aug 10, 2022

Emm... I think it's due to open function in tap property.
Hot reload may reload open function again. But you have opened this port or you don't have any available port. So open is failed.

Maybe you can use if condition to judge open status and port list.

And about last error is 0, it's a bug due to VM. Last error is always 0. So we don't know real error code.
Refer to halildurmus/win32#189

Here is code of line 169 in serial port. It's open exception and it's always fallback to last statement (if VM bug not fixed)

        if (lastError == ERROR_FILE_NOT_FOUND) { 
           throw Exception(_portNameUtf16.toDartString() + "is not available"); 
         } else { 
           throw Exception('Last error is $lastError'); 
         }

By the way, I think the simple way is to use try catch block to ignore this exception. Because last error is always zero...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants