Last active
January 23, 2020 16:24
-
-
Save AlexVegner/ffef4f81cc264234075acc2437aab202 to your computer and use it in GitHub Desktop.
dart_public_private.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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