Home > Net >  Flutter Image can't be assigned to parameter type ImageProvider<Object>
Flutter Image can't be assigned to parameter type ImageProvider<Object>

Time:08-11

CircleAvatar(
  radius: 30,
  backgroundImage: Image.asset("images/bg.png"),
),

Error:

The argument type 'Image' can't be assigned to the parameter type 'ImageProvider?'. (argument_type_not_assignable at [love_messenger] lib\main.dart:85)

What should ı do??

CodePudding user response:

Use

 backgroundImage:AssetImage("images/bg.png") ,
CircleAvatar(
  radius: 30,
  backgroundImage: AssetImage("images/bg.png"),
),

CodePudding user response:

You need to use ImageProvider like this:

    CircleAvatar(
                 radius: 30,
                 backgroundImage: AssetImage('images/bg.png')

Or use child property:

    CircleAvatar(
                 radius: 30,
                 child: Image.asset("images/bg.png")

Have a nice time!

  • Related