Skip to content

_debugCanPerformMutations assert improvements #87423

@Hixie

Description

@Hixie

Right now we assert(_debugCanPerformMutations) in various places, notably markNeedsLayout. We should instead make _debugCanPerformMutations into some sort of validator function that throws useful error messages for each condition that would otherwise have made the assert fail. For example, I just got this:

══╡ EXCEPTION CAUGHT BY FOUNDATION LIBRARY ╞════════════════════════════════════════════════════════
The following assertion was thrown while dispatching notifications for ListViewSelectionController:
'package:flutter/src/rendering/object.dart': Failed assertion: line 1609 pos 12:
'_debugCanPerformMutations': 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      RenderObject.markNeedsLayout (package:flutter/src/rendering/object.dart:1609:12)
#3      RenderBox.markNeedsLayout (package:flutter/src/rendering/box.dart:2320:11)
...

...because my RenderObject was disposed at the time I called markNeedsLayout, but to find that out I had to instrument _debugCanPerformMutations to print out which condition was making it return false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworka: qualityA truly polished experienceframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions