我有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) => {
});
答案 0 :(得分:1)
您必须在子类上定义构造函数。
class B extends A {
bool read;
B({title, content, iconData, onTab, this.read}) : super(title: title, content: content, iconData: iconData, onTab: onTab);
}