我面临问题。我的应用程序在模拟器中运行良好,但在发布模式或移动设备中,它显示以下代码的灰色框。我正在使用 Getx 包。想不通。
请帮忙。
Positioned(
bottom: 0,
child: Obx(() {
if (appBarController.isDataProcessing.value == false) {
if (appBarController.loggedUserData[0] != null) {
return GestureDetector(
onTap: () {
// print('id');
appBarController.getAlumniProfile(
appBarController.loggedUserData[0]['id']);
},
child: Hero(
tag: appBarController.loggedUserData[0]['id'].toString(),
child: appBarController.loggedUserData[0]['user_image'] !=
null
? Container(
height: 50,
width: 50,
decoration: BoxDecoration(
border: Border.all(width: 0.5),
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
appBarController.loggedUserData[0]
['user_image'],
),
),
),
)
: Container(
decoration: BoxDecoration(
border:
Border.all(width: 0.5, color: Colors.white),
shape: BoxShape.circle,
),
child: Icon(
Icons.person,
size: 30,
color: Colors.white,
),
),
),
);
} else {
return Center(
child: SizedBox(),
);
}
} else {
return Center(
child: CircularProgressIndicator(),
);
}
}),
)
谢谢
更新代码(工作代码)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(() {
if (appBarController.isDataProcessing.value == false) {
if (appBarController.loggedUserData[0] != null) {
return GestureDetector(
onTap: () {
// print('id');
appBarController.getAlumniProfile(
appBarController.loggedUserData[0]['id']);
},
child: Hero(
tag: appBarController.loggedUserData[0]['id']
.toString(),
child: appBarController.loggedUserData[0]
['user_image'] !=
null
? Container(
height: 50,
width: 50,
decoration: BoxDecoration(
border: Border.all(width: 0.5),
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
appBarController.loggedUserData[0]
['user_image'],
),
),
),
)
: Container(
decoration: BoxDecoration(
border: Border.all(
width: 0.5, color: Colors.white),
shape: BoxShape.circle,
),
child: Icon(
Icons.person,
size: 30,
color: Colors.white,
),
),
),
);
} else {
return Center(
child: SizedBox(),
);
}
} else {
return Center(
child: CircularProgressIndicator(),
);
}
}),
IconButton(
onPressed: () {
logout();
},
icon: Icon(Icons.exit_to_app),
tooltip: 'Log out',
color: Colors.white,
iconSize: 30,
),
// Text(appBarController.loggedUserData[0]['id'].toString()),
],
)
我学会了解决问题。这对我来说是一种乐趣。谢谢