参数类型 'Object' 无法分配给参数类型 'ImageProvider<Object>?'
The argument type 'Object' can't be assigned to the parameter type 'ImageProvider<Object>?'
由于最近的更新,我遇到了这个问题,请大家帮帮我
late PickedFile _imageFile1, _imageFile2;
final ImagePicker _picker = ImagePicker();
CircleAvatar(
radius: 80.0,
backgroundImage: _imageFile2 == null
? AssetImage("images/default.jpg")
: FileImage(File(_imageFile2.path)),
),
使用child
属性代替backgroundImage
:
CircleAvatar(
radius: 80.0,
child: _imageFile2 == null
? AssetImage("images/default.jpg")
: FileImage(File(_imageFile2.path),
),
),
试试这个,它会起作用。
CircleAvatar(
radius: 80.0,
child: _imageFile2 == null
? Image.asset("images/default.jpg")
: Image.file(File(_imageFile2.path)),
),
由于最近的更新,我遇到了这个问题,请大家帮帮我
late PickedFile _imageFile1, _imageFile2;
final ImagePicker _picker = ImagePicker();
CircleAvatar(
radius: 80.0,
backgroundImage: _imageFile2 == null
? AssetImage("images/default.jpg")
: FileImage(File(_imageFile2.path)),
),
使用child
属性代替backgroundImage
:
CircleAvatar(
radius: 80.0,
child: _imageFile2 == null
? AssetImage("images/default.jpg")
: FileImage(File(_imageFile2.path),
),
),
试试这个,它会起作用。
CircleAvatar(
radius: 80.0,
child: _imageFile2 == null
? Image.asset("images/default.jpg")
: Image.file(File(_imageFile2.path)),
),