我是扑扑的新手,我正在构建一个应用,其中需要将使用image_picker包后生成的文件(图像)转换为要在应用中使用的资产图片。
以下示例代码将创建文件(图像)
import os
from paramiko import SSHClient
host="[HOST}"
user="[USER]"
passs="[PASSWORD]"
client = SSHClient()
client.load_system_host_keys()
client.connect(hostname=host, username=user , password=passs)
stdin, stdout, stderr = client.exec_command('./demo-openrc.sh')
password = input('Please enter your password: ')
stdin.write(password + os.linesep)
print ("stderr: ", stderr.readlines())
print ("pwd: ", stdout.readlines())
预先感谢
答案 0 :(得分:0)
您可以创建一个图像变量,您可以在选择该图像时对其进行验证和更新。
请参见以下代码:
final Function onSelectImage;
ImageInput(this.onSelectImage);
File _storedImage;
Image _tempImage;
Future<void> _takePicture() async {
final imageFile = await ImagePicker.pickImage(
source: ImageSource.camera,
maxWidth: 600,
);
if (imageFile == null) {
return;
}
setState(() {
_storedImage = imageFile;
});
final appDir = await syspaths.getApplicationDocumentsDirectory();
final fileName = path.basename(imageFile.path);
final savedImage = await imageFile.copy('${appDir.path}/$fileName');
widget.onSelectImage(savedImage);
setState(() {
_tempImage = imageFile;
});
}
@override
Widget build(BuildContext context) {
return _tempImage == null ? Container(child:null) : Image(image: _tempImage);
}