please help me I want to show image in listview constructor, image name i stored in database. My image file is stored in Folders Pictures. I retrieve the image to display in the listview builder but the image is not displayed. It seems the code cannot find the image file I have stored in Folders Pictures. What do I need to fix to get the image to show?
class _view_problemState extends State<view_problem> {
TextEditingController _searchController = TextEditingController();
List<problemModel> problemlist = [];
List<problemModel> originalList = [];
StreamController _streamController = StreamController();
Future getAllProblem() async {
problemlist = await problemcontrollers().getProblem();
originalList = problemlist;
_streamController.sink.add(problemlist);
}
Expanded(
child: StreamBuilder(
stream: _streamController.stream,
builder: (context, snapshots) {
if (snapshots.hasData) {
return ListView.builder(
itemCount: problemlist.length,
itemBuilder: ((context, index) {
problemModel problem = problemlist[index];
return Card(
margin: EdgeInsets.all(10),
child: ListTile(
leading: Image.network(
problem.image,
height: 55,
width: 55,
),
title: Text(
problem.name_surname,
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 19),
),
2
Answers
Place your images in
assets
folderThen make changes in
pubspec.yaml
file to access the images from the assets folder like this.Then where you want to display the image
now you will be able to display image like this
I think you want to display images from your api data. So you have to try Image.network in this way.