0

以下代码

class MemberException extends ServerException {
  String message;
  MemberException(message) {
    super(message);
  }
}

class ServerException implements Exception {
  String message;
  ServerException(this.message);
}

产生以下(有点无用)错误消息

Too few arguments in implicit super() constructor invocation in '(String) -> dynamic'
4

1 回答 1

2

正确的格式是:

class MemberException extends ServerException {
  String message;
  MemberException(message) : super(message) {
    // constructor body
  }
}

您需要在调用构造函数主体之前初始化 super 。参考:http ://www.dartlang.org/docs/dart-up-and-running/contents/ch02.html#ch02-constructors (见初始化部分)

于 2013-02-01T11:29:27.413 回答