飞镖 – 颤振相机预览

飞镖 – 颤振相机预览,第1张

概述我是Flutter和Dart的新手,所以请耐心等待. 我正在尝试使用Flutter来显示使用 Camera Plugin的相机预览,并且有两个问题. 1)预览被拉伸,所以事情看起来很奇怪. 2)我想在预览下方显示BottomNavigationBar,但Camera Preview使用所有屏幕空间. 我初始化相机并打开预览: @overrideWidget build(BuildContext 我是Flutter和Dart的新手,所以请耐心等待.
我正在尝试使用Flutter来显示使用 Camera Plugin的相机预览,并且有两个问题. 1)预览被拉伸,所以事情看起来很奇怪. 2)我想在预览下方显示BottomNavigationbar,但Camera PrevIEw使用所有屏幕空间.

我初始化相机并打开预览:

@overrIDeWidget build(BuildContext context) {  if (!_isReady) return new Container();  if (!controller.value.initialized) return new Container();  return new CameraPrevIEw(controller);}

1)这是我称为_CameraWidgetState的类的构建方法.如何让这个预览看起来不舒展?

2)为了使CameraWidget不使用所有空间,我已经尝试将它放在一个没有运气的脚手架中:

Widget build(BuildContext context) {return new Scaffold(  appbar: new Appbar(    Title: new Text(Widget.Title),),body: new Center(    child: new CameraWidget(),bottomNavigationbar: new BottomNavigationbar(    items: [      new BottomNavigationbarItem(          icon: new Icon(Icons.camera),Title: new Text("left")),new BottomNavigationbarItem(          icon: new Icon(Icons.favorite),Title: new Text("Right"))    ],);}

任何想法或帮助表示赞赏!

解决方法 这解决了问题,但也可能有更好的解决方案. (感谢上述评论中的@ user1462442.)

@overrIDeWidget 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,);}
总结

以上是内存溢出为你收集整理的飞镖 – 颤振相机预览全部内容,希望文章能够帮你解决飞镖 – 颤振相机预览所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1001836.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存