Widget _profileInfo(Users profileData) {
return Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
CircleAvatar(
backgroundColor: Colors.grey,
radius: 50.0,
backgroundImage: profileData.photoUrl.isNotEmpty
? NetworkImage(profileData.photoUrl)
: AssetImage("images/user.png"),
)
],
),
SizedBox(
height: 10.0,
),
Text(
profileData.userName,
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold),
),
SizedBox(
height: 10.0,
),
_profileEditButton(),
SizedBox(
height: 10.0,
),
_logoutButton(),
],
),
);
}
答案 0 :(得分:3)
profileData.photoUrl.isNotEmpty
必须
profileData?.photoUrl?.isNotEmpty ?? false
因此,如果未设置 false
或 profileData
,它将默认为 profileData.photoUrl
。