Flutter web : Taken picture stretched only in iOS devices (iPhone)

六月ゝ 毕业季﹏ 提交于 2020-05-17 06:22:07

问题


I'm using this this method and call it. when I take the image directly with the camera on portrait orientation the image get the size of the landscape orientation but it still portrait and stretched.

I'm using universal_html: ^1.2.2

The problem happens just with pictures taken with the iphone camera. picture from gallery are not stretched

import 'package:universal_html/html.dart';

The method

pickImageWeb() async {

html.InputElement input = html.FileUploadInputElement();

input.type = 'file';
input.accept = 'image/*';

input.click();

input.addEventListener('change', (e) {
  // read file content as dataURL
  final files = input.files;
  if (files.length == 1) {
    final file = files[0];
    html.FileReader reader = html.FileReader();

    reader.onLoadEnd.listen((e) {
      setState(() {
        uploadedImage = reader.result;
      });
    });

    reader.onError.listen((fileEvent) {
      setState(() {
        var option1Text = "Some Error occured while reading the file";
      });
    });

    reader.readAsArrayBuffer(file);
  }
});
html.document.body.append(input); }

Call :

floatingActionButton: FloatingActionButton( onPressed: () => pickImageWeb(), child: Icon( Icons.add, color: Colors.black, size: 35, ), ),

Displaying the picture :

Center( child: uploadedImage != null ? Image.memory( uploadedImage, fit: BoxFit.contain, ) : Text( 'Body of the scaffold', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 40, ), ), ),

I opened a Github issue in the universal_html repo Click here

来源:https://stackoverflow.com/questions/61592902/flutter-web-taken-picture-stretched-only-in-ios-devices-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!