剧场模式
首页前端其他Flutter 零基础入门实战视频教程

Flutter 零基础入门实战视频教程 #02 Dart 语言

求知小风 · 元婴发布于新课程
0

https://dartpad.dartlang.org/

void main() {
  List<String> names = ['a', 'b', 'c'];
  names.add('d');
  names.remove('a');
  print(names);
  int age = getAge1();
  print(age);
  greeting();

  User user = User('qiuzhi99', 20);
  print(user.username);
  print(user.age);
  user.login();

  User user1 = User('aaaa', 30);
  print(user1.age);
  print(user1.username);

  SuperUser superUser = SuperUser('cccc', 40);
  print(superUser.age);
  print(superUser.username);

  superUser.login();
  superUser.publish();
}

class User {
  String username;
  int age;

  User(String username, int age) {
    this.username = username;
    this.age = age;
  }

  void login() {
    print('user logined in');
  }
}

void greeting() {
  print('hello');
}

int getAge() {
  return 30;
}

int getAge1() => 31;

class SuperUser extends User {
  SuperUser(String username, int age): super(username, age);

  void publish() {
    print('published update');
  }
}
1 条回复

© 汕尾市求知科技有限公司 | 粤ICP备19038915号 | 关注我们 | 在线学员:116

Top