Skip to content

Instantly share code, notes, and snippets.

@nadetastic
Created January 10, 2022 22:27
Show Gist options
  • Save nadetastic/f8e346dc69cc734ccb12ce6a1da27143 to your computer and use it in GitHub Desktop.
Save nadetastic/f8e346dc69cc734ccb12ce6a1da27143 to your computer and use it in GitHub Desktop.
Some Docs
void main() {
print('>>> Application started... Hello World!');
Admin adminuser = Admin('root', 99);
adminuser.login();
User currentUser = User('Jack u1', 30);
currentUser.login();
print(currentUser.greeting());
adminuser.publish();
currentUser.logout();
}
/* ====================
* Functions in Dart
* ====================
*/
int getAge(){ return 30; }
String hi() => 'Hi There.';
/* ====================
* Types in Dart
* ====================
*/
String name = 'John';
int grade = 100;
dynamic anyType = 'can be string or number';
bool isTrue = true;
List<String> people = [];
/* ====================
* Classes in Dart
* ====================
*/
class User {
String name;
int age;
User(this.name,this.age);
void login() => print('msg: $name has logged in.');
String greeting() => '>>> Hi $name, your are $age years old.';
void logout() => print('msg: $name has been logged out.');
}
class Admin extends User {
Admin(String name, int age) : super(name,age);
void publish() {
print('$name has made core changes***');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment