Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
Created December 18, 2019 19:39
Show Gist options
  • Save ailabs-software/dc3bfd3e1568d5ebb36df205676bdbe4 to your computer and use it in GitHub Desktop.
Save ailabs-software/dc3bfd3e1568d5ebb36df205676bdbe4 to your computer and use it in GitHub Desktop.
Extension method on dynamic
extension on dynamic {
bool get stringNotEmpty => this is String && this.isNotEmpty;
}
void main()
{
Object foo = new Object();
print( foo.stringNotEmpty );
print( "".stringNotEmpty );
print( "Lorde is awesome".stringNotEmpty );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment