我想做的就是添加一个包含字符串列表的新类。一切正常,除了我的类上出现错误,说它需要在最后一个“}”上有一个函数体。我遵循了一个教程,它几乎完全匹配。在教程中,代码不需要在参数之前添加“必需”语句。添加“必需”后,这些错误消失了,但函数体错误仍然存在。这是代码:
class LoginInfo {
String website;
String username;
String password;
LoginInfo(
{required this.website, required this.username, required this.password})
}
Run Code Online (Sandbox Code Playgroud)