【发布时间】:2021-08-01 17:07:48
【问题描述】:
您好,当您使用图像选择器从图库中选择图像时,我想制作它会通过 REST 将其发送到 API。我正在寻找如何做到这一点,但我仍然不明白,我尝试了不同的方法,但总是发生数百万个错误。因此,如果有人知道我将图像作为多部分数据发送到 API 的最佳(最简单)方法是什么,那将意味着全世界。我的目标是将flutters前端与pythons后端连接起来。
到目前为止,这是我的代码:
class _MyHomePageState extends State<MyHomePage> {
Future <File> file;
void openGatePhoto() async {
// ignore: deprecated_member_use
this.setState(() {
file = ImagePicker.pickImage(source: ImageSource.gallery);
});
showDialog(
context: context,
builder: (context) => CustomDialogOpen(
title: "Gates are open",
description:
"Licence plate numbers have been successfully stored in the database",
));
}
此代码的作用是从图库中拍照,然后在您选择它后,它会显示此弹出消息。在此先感谢:D
【问题讨论】:
标签: image api flutter rest dart