如何在Dart / Flutter中扩展课程

时间:2019-07-04 01:28:39

标签: flutter dart

我有A类:

class A{
    String title;
    String content;
    IconData iconData;
    Function onTab;
    A({this.title, this.content, this.iconData, this.onTab});
}

我如何创建使用其他变量扩展类A的类B:

class B extends A{
    bool read;
    B({this.read});
}

尝试过但不起作用

let o = new B(
          title: "New notification",
          iconData: Icons.notifications,
          content: "Lorem ipsum doro si maet 100",
          read: false,
          onTab: (context) => {

          });

1 个答案:

答案 0 :(得分:1)

您必须在子类上定义构造函数。

class B extends A {
  bool read;
  B({title, content, iconData, onTab, this.read}) : super(title: title, content: content, iconData: iconData, onTab: onTab);
}