skip to Main Content

class AddResultPage extends StatelessWidget {
  const AddResultPage({
    Key? key, 
    required this.faceImage, 
    required this.faceName,
    }) : super(key: key);

  final File? faceImage;
  final String faceName;

  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          faceImage == null ? Container() : Image.file(faceImage!),
          // ignore: prefer_const_constructors
          CircleAvatar(
            radius: 50,
            foregroundImage: ,
          ),
          Text(faceName),

how insert image in CircleAvatar?
i don’t know why it is wrong…….

foregroundImage: faceImage,

i don’t know how to use CircleAvatar, file path….

please help….

3

Answers


  1. Chosen as BEST ANSWER

    I solved it!!

    const SizedBox(height: bigSpace),
                    Center(
                      child: CircleAvatar(
                      radius: 80,
                      foregroundImage: FileImage(faceImage!)
                      //faceImage == null ? Container() : Image.file(faceImage!),
                    ),
                  ),
    

  2. You can’t insert a file as an Image, what you can do though is to use

    FileImageCircleAvatar(
        ..
        foregroundImage: FileImage(widget.faceImage),
    ),
    
    Login or Signup to reply.
  3. You are trying to assign the file into the foregroundImage which expects an Image Provider. Since you are trying to display the image from file, you should use FileImage(imageFIle)

    CircleAvatar(
       radius: 50,
       foregroundImage: FileImage(faceImage),     
       backgroundColor: Colors.transparent,
    )
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search