flutter - 选择的图像不会在应用程序的发布版本中呈现
问题描述
我使用颤振开发了一个应用程序,在应用程序的调试版本上一切正常,但是当我使用发布版本进行测试并尝试从相机或画廊添加图像时,图像不会显示在Image.file
Widget
我是用来渲染它。但同样的过程在调试中运行良好。/android/app/src/main/AndroidManifest
我已经为文件添加了权限
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
但似乎没有任何效果。
Widget cameraPhoto() {
return Consumer<HouseHoldViewModel>(builder: (context, vm, _) {
return vm.savedImage.file != null && vm.savedImage.file.toString().isNotEmpty
? ClipOval(
child:
Image.file(
vm.savedImage.file,
height: 86,
width: 86,
fit: BoxFit.fill,
),
): Container(
alignment: Alignment.center,
width: 100,
height: 100,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.cover,
image: vm.pictureUrl != null &&
vm.pictureUrl.isNotEmpty
? CachedNetworkImageProvider(vm.pictureUrl)
: ExactAssetImage('assets/profile_holder.png'))))
;
});
}
这是在我使用选择图像后应该处理图像显示的方法Image picker
void _bottomModal() {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
padding: EdgeInsets.all(6),
height: 100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Consumer<HouseHoldViewModel>(
builder: (context, vm, _) => GestureDetector(
onTap: () => _pickImage(vm, ImageSource.camera),
child: Row(
children: <Widget>[
Icon(Icons.photo_camera),
SizedBox(
width: 10,
),
Text(S.of(context).takeAPicture)
],
),
)),
SizedBox(
height: 20,
),
Consumer<HouseHoldViewModel>(
builder: (context, vm, _) => GestureDetector(
child: Row(
children: <Widget>[
Icon(Icons.photo_library),
SizedBox(
width: 10,
),
Text(S.of(context).chooseFromGallery)
],
),
onTap: () => _pickImage(vm, ImageSource.gallery),
))
],
),
);
});
}
void _pickImage(HouseHoldViewModel vm, ImageSource source) async {
var selected = await ImagePicker.pickImage(source: source);
vm.setSavedImage = selected;
Navigator.pop(context);
}
由于它在我的应用程序的调试版本上运行良好,为什么该版本无法正常工作。请帮我。谢谢你。
解决方案
推荐阅读
- css - 下一部分与第一部分重叠,即使使用 z-index
- flutter - 如何在颤动中设置http超时
- python-3.x - Django webp转换器标签static_webp不起作用
- json - 使用 newtonsoft 反序列化 JSON
- azure-devops - Azure Pipelines 仅获取最新文件
- scheme - 尝试打开使用 raco (macOS) 创建的可执行文件时出现签名错误
- regex - RegEx - 返回 URL 文本字符串右侧的模式
- java - 在edittext android中用于邮政编码(字母数字+数字)的标准Java/Kotlin正则表达式
- vue.js - 来自 sessionStorage 的对象在 vuejs / vuex 中没有反应
- postgresql - 关系中 null 的替代方案