Skip to content

Instantly share code, notes, and snippets.

@ThinkDigitalSoftware
Created August 2, 2019 01:53
Show Gist options
  • Save ThinkDigitalSoftware/2012b9264ee9ec79e8c9800d42d3fbef to your computer and use it in GitHub Desktop.
Save ThinkDigitalSoftware/2012b9264ee9ec79e8c9800d42d3fbef to your computer and use it in GitHub Desktop.
Switch statement using runtimeType in Dart
main(){
var a = B();
switch(a.runtimeType){
case A:{
print ("A");
break;
}
case B:{
print ("B");
break;
}
default:
{
print ("No match. ${a.runtimeType}");
}
}
}
class A {}
class B {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment