I want to show my profile picture which is already saved in my database, while I have fetched name, address etc details from my database but it shows error of late initialization,
late Image _photo ;
if (!jsondata["error"]) {
Shared Preferences preferences = await SharedPreferences.getInstance();
// preferences.setString('user_id', jsondata['uid'] );
controllerName.text = jsondata["user"]["name"];
controllerAddress.text = jsondata["user"]["address"];
controllerContact.text = jsondata["user"]["contact_number"];
setState(() {
_photo = Image.network(jsondata['image']);
});
}
}
Now using here
child: CircleAvatar(
radius: 55,
backgroundColor: Colors.red,
child: _photo != null
? ClipRRect(
borderRadius: BorderRadius.circular(50),
child: _photo,
)
: (_image != null
? ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Image.file(
_image,
width: 100,
height: 100,
fit: BoxFit.fitHeight,
),
)
: Container(
decoration: BoxDecoration(
// color: Colors.grey[200],
borderRadius:
BorderRadius.circular(50)),
width: 100,
height: 100,
child: Icon(
Icons.camera_alt,
// color: Colors.grey[800],
),
)),
),