一旦按下这个图标按钮,就会打开一个howOkCancelAlertDialog,如果您单击ok,就会打开一个showTextInputDialog,将从键盘输入的输入分配给列表类型的输入变量。
IconButton( icon: const Icon(FeatherIcons.arrowRight, color: Colors.black,),
onPressed: () async {
final result = await
showOkCancelAlertDialog(
context: context,
title: 'Change or Create a new Password',
message:
'This will remove your existing Password or create a new one',
);
if (result == OkCancelResult.ok) {
final input = await showTextInputDialog(
textFields: [DialogTextField(keyboardType: TextInputType.numberWithOptions(decimal: true),
),
],
context: context,
title: 'Change or Create a new Password',
message: 'enter your new password',
);
print ("PROVAA PRIMA DELL IF"+input.toString());
context.read<SettingsBloc>().changePassword(input as String);
SettingsPage.inputPassword = input as String;
SettingsPage.inputPassword = tec.text;
setState(() {
encryptedText = encryptAES(SettingsPage.inputPassword);
print("PROVA ENCRYPTED TEXT "+encryptedText);
});
prefs.setString('savedPass', encryptedText);
encryptedText = decryptAES(encryptedText);
print("PROVA TESTO DECRIPTATO " + encryptedText);
}
},
),然而,在执行过程中,我得到了这个错误,因为这个List类型的变量不能赋值给String类型的变量。你能帮我解决这个问题,并确保我可以分配输入,而不会在执行时出现任何问题吗?
发布于 2021-08-06 10:17:46
根据showTextInputDialog文档,很明显它返回List。
您不能使用以下命令将其转换为字符串:
input as String您需要通过index访问这些值,在您的示例中,您可以使用:
input.first as Stringhttps://stackoverflow.com/questions/68679580
复制相似问题