问题
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