Skip to content

Instantly share code, notes, and snippets.

@serpicokhan
Created May 16, 2022 15:43
Show Gist options
  • Select an option

  • Save serpicokhan/19601521f2acadabb18be6d129940107 to your computer and use it in GitHub Desktop.

Select an option

Save serpicokhan/19601521f2acadabb18be6d129940107 to your computer and use it in GitHub Desktop.
//extension to convert a string to a number
extension NumberParsing on String {
int customParseInt() {
return int.parse(this);
}
double customParseDouble() {
return double.parse(this);
}
}
void main() {
//various ways to use the extension
var d = '21'.customParseDouble();
print(d);
var i = NumberParsing('20').customParseInt();
print(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment