12

This is a follow-up to this Dart question.

Since Flutter doesn't support reflection and we can't use mirrors, how would you go about debugging, let's say an instance of firebase_database DatabaseReference ? I'm trying to write tests, and knowing what key/values my reference contains will make it easier for me to write a proper test.

Adrien Lemaire
  • 1,744
  • 2
  • 20
  • 29

2 Answers2

32

since Dart 3.12 you can use inspect(object) to achieve this

omidh
  • 2,526
  • 2
  • 20
  • 37
2

If you expect to have a built-in easy solution, then sorry : You can't.

BUT you can use plugins to serialize your own code, such as built_value. And print the serialized object.

On the other hand, if you want to print external code (DatabaseReference for instance), you'll have to manually transform that object in a combination of Map, List, and int/String/double.

Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432