我正在使用下面的代码从flutter应用程序中的库中获取图像,它在Android中运行正常,并且已成功将图像上传到Firebase存储中,但是在iOS应用程序中使用相同图像时,当在IconButton
中点击Container
并在日志中我收到以下消息后,调用方法'getImage()'
Lost connection to device.
Future getImage() async {
File image = await ImagePicker.pickImage(source: ImageSource.gallery);
if (image != null) {
setState(() {
avatarImageFile = image;
isLoading = true;
});
}
}
Container(
child: Center(
child: Stack(
children: <Widget>[
(avatarImageFile == null)
? (photoUrl != ''
? Material(
child: CachedNetworkImage(
placeholder: (context, url) => Container(
child: CircularProgressIndicator(
strokeWidth: 2.0,
valueColor: AlwaysStoppedAnimation<Color>(themeColor),
),
width: 90.0,
height: 90.0,
padding: EdgeInsets.all(20.0),
),
imageUrl: photoUrl,
width: 90.0,
height: 90.0,
fit: BoxFit.cover,
),
borderRadius: BorderRadius.all(Radius.circular(45.0)),
clipBehavior: Clip.hardEdge,
)
: Icon(
Icons.account_circle,
size: 90.0,
color: greyColor,
))
: Material(
child: Image.file(
avatarImageFile,
width: 90.0,
height: 90.0,
fit: BoxFit.cover,
),
borderRadius: BorderRadius.all(Radius.circular(45.0)),
clipBehavior: Clip.hardEdge,
),
IconButton(
icon: Icon(
Icons.camera,
color: primaryColor.withOpacity(0.5),
),
onPressed: getImage,
padding: EdgeInsets.all(30.0),
splashColor: Colors.transparent,
highlightColor: greyColor,
iconSize: 30.0,
),
],
),
),
width: double.infinity,
margin: EdgeInsets.all(20.0),
),