且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

颤振相机预览

更新时间:2023-02-02 20:35:14

这可以解决问题,但也可以有更好的解决方案。 (感谢@ user1462442,来自上面的评论。)

This solves the problem, but there could be better solutions as well. (Thanks to @user1462442 from the comments above.)

@override
Widget build(BuildContext context) {
 if (!_isReady) return new Container();
 if (!controller.value.initialized) return new Container();

 return new Scaffold(
   body: new Container(
     child: new AspectRatio(
       aspectRatio: controller.value.aspectRatio,
       child: new CameraPreview(controller),
     ),
   ),
   floatingActionButton: new FloatingActionButton(
     onPressed: _isReady ? capture : null,
     child: const Icon(
       Icons.camera,
       color: Colors.white,
     ),
   ),
   floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
 );
}