Enrich the Flutter Inspector with Diagnosticable properties

Diagnosticable for Custom Classes

Let’s create a new class called ColorSheme with Diagnosticable mixin and add it as a state to the _MyHomePageState:

Result

Bonus

When you override debugFillProperties you don’t need to override toString explicitly. The mixin will add some nice formatting for you.

MyColorScheme#606ef(textColor: Color(0xff000000), backgroundColor: Color(0xffffffff))

Tip

If you’re using Intellij simply press Option/Alt + Enter on any public property of a class.
Then select Add a debug reference to this property. It will automatically override the debugFillProperties method and add an entry for this property.

Note

Be cautious of what you add to the Diagnosticable properties and do not clutter it with unnecessary information. Make sure you only add information which will be useful for debugging.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store