Skip to content

Instantly share code, notes, and snippets.

@benznest
Created March 17, 2019 07:59
Show Gist options
  • Save benznest/3fe0189b9fc611efd4859fe0912764b9 to your computer and use it in GitHub Desktop.
Save benznest/3fe0189b9fc611efd4859fe0912764b9 to your computer and use it in GitHub Desktop.
Initializing field in Dart
class Spacecraft{
String name;
bool available;
Spacecraft(this.name,this.available);
}
class Astronaut{
String name;
}
main(){
Spacecraft sc = Spacecraft("USS Discovery" , true);
print(sc?.name); // USS Discovery
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment