Home > front end >  flutter Insert pictures from the previous page
flutter Insert pictures from the previous page

Time:12-06


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....

CodePudding user response:

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

FileImageCircleAvatar(
    ..
    foregroundImage: FileImage(widget.faceImage),
),

CodePudding user response:

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,
)

  • Related