Skip to content

<evalError>:<collected> on inspecting Map #2780

Closed

Description

@ajain-bst

I just upgraded to Flutter v20 and tried using the new support for inspect to print my network call logs.

Sometimes it does work and I can see the inspected Map:
Example of when it works

But sometimes I see the following printed to the console:
Example of when it does not work

Any idea why this is happening?

Activity

  1. DanTup commented on Sep 8, 2020

    @DanTup
    Member

    My guess is that the variable has been garbage-collected prior to you expanding it. Calling inspect() won't prevent an object from being collected, and the expansion in the debug console is done lazily. If the variable went out of scope and got collected, there's no way to show its data.

    As a workaround if you want to inspect variables that would usually be collected, you could (temporarily) add them to a top-level/static List or something (though be sure not to leave that in non-debug code!).

    If you can reproduce this on something that you don't think should've been collected, please provide a code sample and I'll try to reproduce. Thanks!

  2. added
    awaiting info
    on Sep 8, 2020
  3. ajain-bst commented on Sep 8, 2020

    @ajain-bst
    Author

    Understood! Thanks for the quick response @DanTup :)
    Closing this.

  4. removed
    awaiting info
    on Sep 8, 2020
  5. amalmohann commented on Apr 8, 2022

    @amalmohann

    If you've declared the variable locally inside any block, try to change it to a higher scope.
    I've declared the variable along with other class members and now the issue is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions