我正在尝试按照本指南和本视频将我的一个项目迁移到空安全,但我在升级我的依赖项和在 Web 界面中查看迁移建议之间陷入了困境。我设法将我的项目从 Flutter 1 升级到 Flutter 2,以将所有依赖项更新到它们的 null 安全版本,除了 build_runner 作为开发依赖项,但显然我们可以忽略它。现在,当我运行时dart migrate
,这就是我在终端中得到的:
Analyzing project...
[---------------------------------------------------------------------------------------------------------------------------------------------------------------\]
23 analysis issues found:
error • The named parameter 'email' isn't defined at lib/screens/email_screen.dart:38:11 • (undefined_named_parameter)
error • The named parameter 'password' isn't defined at lib/screens/email_screen.dart:39:11 • (undefined_named_parameter)
error • The named parameter 'errorText' isn't defined at lib/screens/email_screen.dart:124:29 • (undefined_named_parameter)
error • The named parameter 'errorText' isn't defined at lib/screens/email_screen.dart:128:29 • (undefined_named_parameter)
error • The named parameter 'errorText' isn't defined at lib/screens/first_name_screen.dart:112:27 • (undefined_named_parameter)
error • The named parameter 'data' isn't defined at lib/screens/onboarding_screen.dart:47:17 • (undefined_named_parameter)
error • The named parameter 'styleSheet' isn't defined at lib/screens/onboarding_screen.dart:49:17 • (undefined_named_parameter)
error • The named parameter 'onTapLink' isn't defined at lib/screens/onboarding_screen.dart:59:17 • (undefined_named_parameter)
error • The named parameter 'verificationId' isn't defined at lib/screens/phone_code_screen.dart:77:9 • (undefined_named_parameter)
error • The named parameter 'smsCode' isn't defined at lib/screens/phone_code_screen.dart:78:9 • (undefined_named_parameter)
error • The named parameter 'phoneNumber' isn't defined at lib/screens/phone_code_screen.dart:149:7 • (undefined_named_parameter)
error • The named parameter 'verificationCompleted' isn't defined at lib/screens/phone_code_screen.dart:150:7 • (undefined_named_parameter)
error • The named parameter 'verificationFailed' isn't defined at lib/screens/phone_code_screen.dart:156:7 • (undefined_named_parameter)
error • The named parameter 'codeSent' isn't defined at lib/screens/phone_code_screen.dart:159:7 • (undefined_named_parameter)
error • The named parameter 'codeAutoRetrievalTimeout' isn't defined at lib/screens/phone_code_screen.dart:166:7 • (undefined_named_parameter)
error • The named parameter 'forceResendingToken' isn't defined at lib/screens/phone_code_screen.dart:171:7 • (undefined_named_parameter)
error • The named parameter 'errorText' isn't defined at lib/screens/phone_code_screen.dart:288:31 • (undefined_named_parameter)
error • The named parameter 'errorText' isn't defined at lib/screens/phone_code_screen.dart:293:31 • (undefined_named_parameter)
error • The named parameter 'phoneNumber' isn't defined at lib/screens/phone_number_screen.dart:49:9 • (undefined_named_parameter)
error • The named parameter 'verificationCompleted' isn't defined at lib/screens/phone_number_screen.dart:50:9 • (undefined_named_parameter)
error • The named parameter 'verificationFailed' isn't defined at lib/screens/phone_number_screen.dart:57:9 • (undefined_named_parameter)
error • The named parameter 'codeSent' isn't defined at lib/screens/phone_number_screen.dart:92:9 • (undefined_named_parameter)
error • The named parameter 'codeAutoRetrievalTimeout' isn't defined at lib/screens/phone_number_screen.dart:102:9 • (undefined_named_parameter)
Note: analysis errors will result in erroneous migration suggestions.
Please fix the analysis issues (or, force generation of migration suggestions by re-running with --ignore-errors).
现在,如果我以前两个错误为例,这里是它指向的代码行:
final emailCredential = EmailAuthProvider.credential(
email: _emailAddress.trim(),
password: randomPassword,
);
从 Firebase Auth 调用这段代码:
/// Creates a new [EmailAuthCredential] from a given email and password.
static AuthCredential credential({
required String email,
required String password,
}) {
return EmailAuthCredential._credential(email, password);
}
正如你所看到的,两个命名参数都定义得很好,所以我真的不明白问题出在哪里。我检查了所有其他错误,它们是相同的:所有命名参数都存在并且实际上已定义。
我错过了什么?我可以安全地忽略这些错误并继续进行其余的迁移吗?