【问题标题】:how to convert image captured with camera to base64 with flutter如何将相机捕获的图像转换为带有颤振的base64
【发布时间】:2020-09-22 11:19:40
【问题描述】:

我想将用相机捕获的图像转换为base64,但似乎是在转换图像路径而不是图像本身,请帮助我。

File file;
final picker = ImagePicker();
void _choose() async {
  final pickedFile = await picker.getImage(source: ImageSource.camera);
  file = File(pickedFile.path);
  if (file != null) {
    setState(() {
      base64Encode(file.readAsBytesSync());
      print(base64Encode(Image.file(file));
    });
  }
}

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies flutter-animation flutter-test


    【解决方案1】:

    错误:

    print(base64Encode(Image.file(file));
    

    对:

    print(base64Encode(file.readAsBytesSync()));
    

    【讨论】:

    • 您能否提供有关您的代码功能的更多详细信息?
    猜你喜欢
    • 1970-01-01
    • 2021-01-19
    • 1970-01-01
    • 2019-07-23
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-02
    相关资源
    最近更新 更多