问题
Iam using CameraPreview for measuring height of an object,But the issue was i cant able to set cameraPreview height full screen..
I have tried Positioned widget, it fills the screen but the image was stretched. I have tried Transform Widget, but height does not fills fullscreen, white space is coming.Image is not stretched.
Mycode:
final size = MediaQuery.of(context).size;
final deviceRatio = size.width / size.height;
return Stack(
children: <Widget>[
Transform.scale(
scale: controller.value.aspectRatio/deviceRatio,
child: new AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: new CameraPreview(controller),
),
),);
Kindly help me to fit CameraPreview "FULLSCREEN" without image streching..
回答1:
Issue has been solved by wrapping Centre widget in Transform widget
final size = MediaQuery.of(context).size;
final deviceRatio = size.width / size.height;
return Stack(
children: <Widget>[
Center(
child:Transform.scale(
scale: controller.value.aspectRatio/deviceRatio,
child: new AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: new CameraPreview(controller),
),
),),);
来源:https://stackoverflow.com/questions/56735552/how-to-set-flutter-camerapreview-size-fullscreen