Last active
May 28, 2021 12:53
-
-
Save abhaysood/e5808b221c3ece51408b60f39ef5b4b8 to your computer and use it in GitHub Desktop.
Blog: Enrich the Flutter Inspector with Diagnosticable properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyColorScheme with Diagnosticable { | |
final Color textColor; | |
final Color backgroundColor; | |
MyColorScheme(this.textColor, this.backgroundColor); | |
@override | |
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | |
super.debugFillProperties(properties); | |
properties.add(ColorProperty('textColor', textColor)); | |
properties.add(ColorProperty('backgroundColor', backgroundColor)); | |
} | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
late MyColorScheme _myColorScheme; | |
int _counter = 0; | |
@override | |
void initState() { | |
_myColorScheme = MyColorScheme(Colors.black, Colors.white); | |
super.initState(); | |
} | |
@override | |
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | |
super.debugFillProperties(properties); | |
properties.add(IntProperty('_counter', _counter)); | |
properties.add( | |
DiagnosticsProperty<MyColorScheme>('myColorScheme', _myColorScheme)); | |
} | |
// Code omitted for brevity. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment