Ahmed Rajab
Ahmed Rajab

Reputation: 701

Error: Assertion failed: !_debugDuringDeviceUpdate is not true flutter

I am facing this error when using adding some widgets like ListView to a flutter web project I never faced it before when working with android

    Exception has occurred.
"Error: Assertion failed: file:///D:/Android/flutter/packages/flutter/lib/src/rendering/mouse_tracking.dart:312:12
!_debugDuringDeviceUpdate
is not true
    at Object.throw_ [as throw] (http://localhost:23584/dart_sdk.js:4328:11)
    at Object.assertFailed (http://localhost:23584/dart_sdk.js:4275:15)
    at mouse_tracking.MouseTracker.new.[_deviceUpdatePhase] (http://localhost:23584/packages/flutter/src/rendering/layer.dart.lib.js:4940:61)
    at http://localhost:23584/packages/flutter/src/rendering/layer.dart.lib.js:4998:33
    at mouse_tracking.MouseTracker.new.[_monitorMouseConnection] (http://localhost:23584/packages/flutter/src/rendering/layer.dart.lib.js:4935:7)
    at mouse_tracking.MouseTracker.new.updateWithEvent (http://localhost:23584/packages/flutter/src/rendering/layer.dart.lib.js:4997:36)
    at binding$5.WidgetsFlutterBinding.new.dispatchEvent (http://localhost:23584/packages/flutter/src/rendering/layer.dart.lib.js:5943:45)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerEvent] (http://localhost:23584/packages/flutter/src/gestures/binding.dart.lib.js:257:14)
    at binding$5.WidgetsFlutterBinding.new.[_flushPointerEventQueue] (http://localhost:23584/packages/flutter/src/gestures/binding.dart.lib.js:229:35)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (http://localhost:23584/packages/flutter/src/gestures/binding.dart.lib.js:213:65)
    at Object._invoke1 (http://localhost:23584/dart_sdk.js:175453:7)
    at _engine.EngineWindow.new.invokeOnPointerDataPacket (http://localhost:23584/dart_sdk.js:171307:15)
    at _engine.PointerBinding.__.[_onPointerData] (http://localhost:23584/dart_sdk.js:158211:24)
    at http://localhost:23584/dart_sdk.js:158585:26
    at http://localhost:23584/dart_sdk.js:158557:16
    at http://localhost:23584/dart_sdk.js:158310:11"

I looked everywhere but with no clues thanks in advance

Upvotes: 16

Views: 39521

Answers (9)

Ewo Prince
Ewo Prince

Reputation: 1

I have this same issue, I fixed it by taking the expanded widget off the widget tree.

Upvotes: 0

Abdullah Alamodi
Abdullah Alamodi

Reputation: 329

In may case it was SelectionArea in the main layout (custom layout applied for all pages).

Upvotes: 0

George Freire
George Freire

Reputation: 47

My solution was to enlarge the screen with the size property of the Container

Container(
        width: MediaQuery.of(_buildContext!).size.width 
)

Upvotes: 0

Denxorz
Denxorz

Reputation: 346

Accidentially swapping a Column for a Row might also stir up errors like these.

Upvotes: 0

Reetesh Ranjan
Reetesh Ranjan

Reputation: 109

I had this assertion failure happening because I was using a MouseRegion subtree, where the onEnter/onExit handlers were throwing an uncaught exception specific to my app. Once the app's exception occurred, this assertion failure occurred, and after that no clickable element will show the proper cursor.

Once I got rid of the uncaught exception coming form onEnter/onExit handlers, this assertion failure stopped happening.

https://github.com/flutter/flutter/issues/84241#issuecomment-1236344314.

Upvotes: 1

user1634451
user1634451

Reputation: 5212

I had the same problem with a row and needed to put Expaned() around the list view

Upvotes: 0

ervans589
ervans589

Reputation: 249

Sometimes, assets need re-rendering in order to update dynamically. So, Instead of hot reloading, try hot restarting, or close the app and rebuild it.

Upvotes: 24

Ayesha Iftikhar
Ayesha Iftikhar

Reputation: 400

Can you please share the code? Because I also faced the same error but I have resolved it. Apparently, I was using a Row() widget in the Trailing of my ListTile() widget. So I just add the following property in my Row() widget

mainAxisSize: MainAxisSize.min

But, I still suggest you please share the piece of code too which is throwing that error so that someone suggests an answer more accurately.

Upvotes: 3

Devang Raj Arora
Devang Raj Arora

Reputation: 131

I was also facing the same issue. But in my case I noticed there was another error which said

Vertical viewport was given unbounded height.

Adding these two lines to ListView should fix the error:

scrollDirection: Axis.vertical,
shrinkWrap: true,

Upvotes: 13

Related Questions