当我转换为 Null-safe 时,我就是这个,并且我不断收到此错误
这是我的代码
try {
final AuthorizationResult appleResult =
await TheAppleSignIn.performRequests([
AppleIdRequest(requestedScopes: [Scope?.email, Scope?.fullName])
]);
if (appleResult.error != null) {
// handle errors from Apple here
}
final AuthCredential credential = OAuthProvider('apple.com').credential(
accessToken:
String.fromCharCodes(appleResult.credential!.authorizationCode),//here the error coming out.... i have also try Uint8List.fromList but still showing the error
idToken: String.fromCharCodes(appleResult.credential!.identityToken),//here the error coming out.... i have also try Uint8List.fromList but still showing the error
);
final firebaseResult = await auth.signInWithCredential(credential);
users = firebaseResult.user;
if (users == null) {
return false;
}
return true;
} catch (error) {
print(error);
return false;
}
我也试过
Uint8List.from()
答案 0 :(得分:0)
问题:
您的 Uint8List?
是可空的,而 Iterable<int>
是不可空的,因此您不能将可空分配给不可空。
解决方案:
如果 Unit8List?
可以是 null
,请提供一个默认值。
Iterable<int> iterable = yourUint8List ?? [];
如果 Uint8List?
不能为 null
,请使用 bang 运算符。
Iterable<int> iterable = yourUint8List!;