我在玩 dart 语法
我正在尝试这个代码:
WebDriverWait
我得到的错误信息是
void main() {
print("Hello to demo");
try{
throw Test("hello");
}
on Test catch(Test e,StackTrace s){ //error on this line
print("error message is ${(e).message}");
}
}
class Test{
String? message;
Test(this.message);
}
我知道 dart 是强类型语言,但同时显式定义类型是可选的,但我不知道为什么我会在这里收到此消息,是否存在某些情况(例如此处的 'catch' must be followed by '(identifier)' or '(identifier,identifier)'.
No types are needed,the first is given by 'on',the second is always 'StackTrace'
)甚至指定类型是被禁止的,甚至不是可选的?
ps:我正在阅读文档 here