【问题标题】:how to rename the image from image picker in flutter?如何在颤动中重命名图像选择器中的图像?
【发布时间】:2020-11-19 12:54:35
【问题描述】:

我正在从图库中挑选图片/使用 image_picker: ^0.6.7+4 包拍照。

void takePhoto(ImageSource source) async {
final pickedFile = await _picker.getImage(
  source: source,
);
setState(() {
  _imageFile = pickedFile;
});
}

我得到的图像名称为

image_picker_A0EBD0C1-EF3B-417F-9F8A-5DFBA889118C-18492-00001AD95CF914D3.jpg

现在我想重命名图像。

如何重命名?

【问题讨论】:

标签: image flutter rename gallery imagepicker


【解决方案1】:

您需要先将该图像保存在某个位置,然后才能对其进行重命名。试试这个:

void takePhoto(ImageSource source) async{
  final image = await ImagePicker().getImage(source: source);
  final newImage = File('${(await getTemporaryDirectory()).path}/your_name.jpg');
}

【讨论】:

    猜你喜欢
    • 2020-05-10
    • 2021-11-06
    • 2018-10-31
    • 2021-12-25
    • 2020-12-13
    • 2019-02-09
    • 2021-12-02
    • 1970-01-01
    • 2023-01-04
    相关资源
    最近更新 更多