Repository: flutter
Issue:  'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 224 pos 12: '(event is PointerAddedEvent) == (lastEvent is PointerRemovedEvent)': is not true. when emulation touches on a mobile device with a mouse
Labels: platform-android,framework,f: gestures,a: error message,a: mouse,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.27,found in release: 3.28

### Steps to reproduce

Just Tap on the Mobile Screen with the help of TouchPad of your laptop

### Expected results

It should not come and not shown in the terminal

### Actual results

Getting the Issue -> 
══╡ EXCEPTION CAUGHT BY GESTURES LIBRARY ╞══════════════════════════════════════════════════════════
The following assertion was thrown while handling a pointer data packet:
'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 224 pos 12: '(event is
PointerAddedEvent) == (lastEvent is PointerRemovedEvent)': 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.yml

When the exception was thrown, this was the stack:
#2      MouseTracker._shouldMarkStateDirty (package:flutter/src/rendering/mouse_tracker.dart:224:12)
#3      MouseTracker.updateWithEvent (package:flutter/src/rendering/mouse_tracker.dart:318:10)
#4      RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:20)
#5      GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:427:7)
#6      GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:390:5)
#7      GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:337:7)
#8      GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:306:9)
#9      _invoke1 (dart:ui/hooks.dart:328:13)
#10     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:450:7)
#11     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
(elided 2 frames from class _AssertionError)
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: 'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 224 pos 12: '(event is PointerAddedEvent)
== (lastEvent is PointerRemovedEvent)': is not true.

### Code sample

══╡ EXCEPTION CAUGHT BY GESTURES LIBRARY ╞══════════════════════════════════════════════════════════
The following assertion was thrown while handling a pointer data packet:
'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 224 pos 12: '(event is
PointerAddedEvent) == (lastEvent is PointerRemovedEvent)': 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.yml

When the exception was thrown, this was the stack:
#2      MouseTracker._shouldMarkStateDirty (package:flutter/src/rendering/mouse_tracker.dart:224:12)
#3      MouseTracker.updateWithEvent (package:flutter/src/rendering/mouse_tracker.dart:318:10)
#4      RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:20)
#5      GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:427:7)
#6      GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:390:5)
#7      GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:337:7)
#8      GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:306:9)
#9      _invoke1 (dart:ui/hooks.dart:328:13)
#10     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:450:7)
#11     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
(elided 2 frames from class _AssertionError)
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: 'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 224 pos 12: '(event is PointerAddedEvent)
== (lastEvent is PointerRemovedEvent)': is not true.

### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

<img width="1141" alt="Screenshot 2024-12-12 at 1 07 14 PM" src="https://github.com/user-attachments/assets/5fde0e5f-ead2-45e3-9496-48ac18c158c5" />


</details>


### Logs

<details open><summary>Logs</summary>

```console

======== Exception caught by gestures library ======================================================
The following assertion was thrown while handling a pointer data packet:
'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 224 pos 12: '(event is PointerAddedEvent) == (lastEvent is PointerRemovedEvent)': 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.yml

When the exception was thrown, this was the stack: 
#2      MouseTracker._shouldMarkStateDirty (package:flutter/src/rendering/mouse_tracker.dart:224:12)
#3      MouseTracker.updateWithEvent (package:flutter/src/rendering/mouse_tracker.dart:318:10)
#4      RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:20)
#5      GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:427:7)
#6      GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:390:5)
#7      GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:337:7)
#8      GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:306:9)
#9      _invoke1 (dart:ui/hooks.dart:328:13)
#10     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:450:7)
#11     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
(elided 2 frames from class _AssertionError)
====================================================================================================
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.0, on macOS 15.1.1 24B91 darwin-arm64 (Rosetta), locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.89.1)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for Hardik's iPhone. Ensure the device is unlocked and attached with a cable or associated with
      the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for AKSHAY DAHIYA’s iPhone. Ensure the device is unlocked and attached with a cable or associated
      with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for Himanshu’s iPhone. Ensure the device is unlocked and attached with a cable or associated with
      the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!
```

</details>