Skip to content

Instantly share code, notes, and snippets.

@atreeon
Last active May 14, 2024 12:16
Show Gist options
  • Save atreeon/48941d624906054513318852e4d0cf1a to your computer and use it in GitHub Desktop.
Save atreeon/48941d624906054513318852e4d0cf1a to your computer and use it in GitHub Desktop.
Typedef types
/*
An easy way to create a new type in Dart is using typedef.
The type is of course a named record so the underlining type would match any record where the property types are named the same.
*/
typedef BarAndSpaceWidth = ({int barWidth, int spaceWidth});
BarAndSpaceWidth getBarAndSpaceWidth() {
var blah = (barWidth: 10, spaceWidth: 20);
return blah;
}
main() {
var result = getBarAndSpaceWidth();
print(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment