Home > Software engineering >  'Object' can't be assigned to the parameter type 'ImageProvider<Object>�
'Object' can't be assigned to the parameter type 'ImageProvider<Object>�

Time:04-18

I get following error when using Circle Avatar:

The argument type 'Object' can't be assigned to the parameter type 'ImageProvider'

This is the code:

CircleAvatar(
   backgroundImage: snapshot.data['imageUrl'] == "" 
    ? AssetImage('assets/img.png')
    : NetworkImage(snapshot.data['imageUrl']));

Picture of the code and error

CodePudding user response:

this is currently an open issue on GitHub with dart 2.12.

As a workaround you can cast the object

AssetImage('assets/img.png') as ImageProvider,
  • Related