Dart / Flutter error: 'toStringDeep' isn't defined for the class 'Logger'

3,764

Solution 1

When I get this error, I use "flutter clean" and it solves the problem.

Solution 2

I ran into a similar issue, for me It only happens with Android Studio's interface run/debug button. It was working fine with flutter run command.

But clearing out the build files/cache fixed the issue.

1. Android Studio:

Menu Tool > Flutter > Flutter Clean

 

2. OR run the command on CLI:

flutter clean

 

3. Using shortcut

It doesn't have a default key shortcut to run flutter clean, but you can add one easily.
I added + H hotkey for flutter clean. You can define yours. Here is how:

  1. Open Preferences/Settings.

enter image description here

  1. Click on Keymap
  2. Search for flutter clean.
  3. Right click on Flutter Clean and select Add Keyboard shortcut

enter image description here

  1. Add the keyboard short cut you prefer. I added Command + H

enter image description here

Now you can do it quicker.

Solution 3

alternatively, just remove the build folder.

Solution 4

Running flutter clean in terminal solves this for me. Annoying bug that happens quite often right now.

Solution 5

run in Terminal :

flutter clean
Share:
3,764
Francesco Iapicca
Author by

Francesco Iapicca

Self taught developer in love with Flutter and Dart

Updated on December 10, 2022

Comments

  • Francesco Iapicca
    Francesco Iapicca over 1 year

    Aye aye good people,

    after several runs of debugging, suddenly... logging suddenly return me this error:

    Compiler message: org-dartlang-debug:synthetic_debug_expression:1:1: Error: Method not found: 'toStringDeep'. toStringDeep() ^^^^^^^^^^^^ org-dartlang-debug:synthetic_debug_expression:1:1: Error: The method 'toStringDeep' isn't defined for the class 'Logger'. - 'Logger' is from 'package:logging/logging.dart' ('file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.3+2/lib/logging.dart').

    "toStringDeep" isn't my stuff, probably used in logging; I tried to go back on my steps and remove the log(?) I've added, but still returns the same error.

    any help? pretty please...

    Francesco

  • Francesco Iapicca
    Francesco Iapicca about 5 years
    works, as also Andre suggested, the absurd part is that I have to do it every time i run it :( plus suddenly isn't showing the logs anymore :/
  • Lahar Shah
    Lahar Shah about 5 years
    If you add a keyboard short cut for flutter clean, that would make it little easier to run, I just updated the answer with that.
  • Ashutosh Anand
    Ashutosh Anand about 4 years
    I tried with only 1st Step and it worked. Thanks :)