Created
May 2, 2022 05:35
-
-
Save AbdullohBahromjonov/b3ceb63b64521fb729a3ebe38a7f0bed to your computer and use it in GitHub Desktop.
Dart Classes
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
class Person { | |
final String name; | |
final int age; | |
Person(this.name, this.age); | |
Person.born() : name = 'Abdulloh', age = 15; | |
factory Person.zero() { | |
final one = Person.born().age-7; | |
return Person('Zinnura', one); | |
} | |
} | |
void main() { | |
final unknowPerson = Person('Kamola', 17); | |
final unknowPersonName = unknowPerson.name; | |
final unknowPersonAge = unknowPerson.age; | |
final abdulloh = Person.born(); | |
final abdullohName = abdulloh.name; | |
final abdullohAge = abdulloh.age; | |
print('$unknowPersonName: $unknowPersonAge'); | |
print('$abdullohName: $abdullohAge'); | |
print(Person.zero().age); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment