Skip to content

Instantly share code, notes, and snippets.

@AlexVegner
Last active January 23, 2020 16:24
Show Gist options
  • Select an option

  • Save AlexVegner/ffef4f81cc264234075acc2437aab202 to your computer and use it in GitHub Desktop.

Select an option

Save AlexVegner/ffef4f81cc264234075acc2437aab202 to your computer and use it in GitHub Desktop.
dart_public_private.dart
// If name of variable, function, class, method etc. stars with ‘_’ then it's visible only inside this file.
// Example 1:
String _str1 = 'Hello'; // private
String str2 = "World"; // public
// Example 2
void main() {
final car = Car('Audi', 'A8');
print('model: ${car._model}'); // visible only inside of the file
}
class Car {
final String _model;
final String name;
Car(this._model, this.name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment