Pankaj
Pankaj

Reputation: 111

Flutter: The getter 'image' was called on null

I'm retrieving images from API:

  base64FormatImage = base64FormatImage.toString();
  base64FormatImage = base64FormatImage.replaceAll('data:image/jpeg;base64,', '');
  base64FormatImage = base64FormatImage.replaceAll('}', '');
  base64FormatImage = base64FormatImage.replaceAll('data:image/jpegbase64,', '');
  courseImage = imageFromBase64String(base64FormatImage);

Images are getting retrieved, but the screen shows "The getter 'image' was called on null" for about a second or two and after a second or two, the screen shows the proper image.

Why does this happen? Why is it taking some time?

Upvotes: 0

Views: 425

Answers (1)

Akif
Akif

Reputation: 7640

You can check your courseImage before using it.

   courseImage == null ?
      Container() :
      CircleAvatar(backgroundImage: courseImage.image)

Upvotes: 1

Related Questions