0

final PlatformFile image; final double size;

decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.cover, image: AssetImage(image.path!), ),

3 Answers 3

2

you need to used FileImage instead of AssetImage

            decoration: new BoxDecoration(
                color: Colors.transparent,
                image: new DecorationImage(
                  image: new FileImage(File(image.path)),
                  fit: BoxFit.cover,
                ),
        
              ),
Sign up to request clarification or add additional context in comments.

2 Comments

@hassan yassin if your image load using this code then please make a right answer.
THANKS BRO, SOLVED
1

Use FileImage instead of AssetImage if you are trying to take from local path.

Comments

0
 You can also do one thing check the _image value if it null shows image through your assets if not then you call it through FileImage(_image!)

//////code   
File ?_image;
       
     _image==null?Stack(
                              children: [
                                Container(
                                  height: 150,
                                  width:_width,
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Container(
                                        height: 120,
                                        width: 120,
                                        decoration: BoxDecoration(
                                            color: Colors.white,
                                            borderRadius: BorderRadius.circular(60),
                                            border: Border.all(color: AppColors.white, width: 2.0),
                                            image: DecorationImage(
                                              image: AssetImage("assets/managerPicture.jpeg"),fit: BoxFit.cover,
                                            )
                                          /*gradient: LinearGradient(
                                  begin: Alignment.topRight,
                                  end: Alignment.bottomLeft,
                                  colors: [
                                    Color(0xff00519E),
                                    AppColors.blue,
                                    Colors.blue.shade900,
                                  ],
                                )*/
                                        ),
                                        /* child: ClipRRect(
                                borderRadius: BorderRadius.circular(60.0),
                                child: Image.asset("assets/manager.jpeg",height: 100,width: 100,)
                              //Icon(Icons.person, size: 100),
                              // child: Image.asset("assets/logo/profile.png", fit: BoxFit.fill),
                            ),*/
                                      ),
                                    ],
                                  ),
                                ),
                                Positioned(
                                  top: 60,
                                  right: 0,
                                  left: 100,
                                  bottom: 0,
                                  child: GestureDetector(
                                    onTap: (){
                                      _showChoiceDialog(context);
                                    },
                                    child: Container(
                                      height: 10,
                                      width: _width,
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            height: 35,
                                            width: 35,
                                            decoration: BoxDecoration(
                                              color: AppColors.profiePicBackground,
                                              borderRadius: BorderRadius.circular(60),
        
                                              //border: Border.all(color: Colors.blue.shade900, width: 2.0),
                                            ),
                                            child: ClipRRect(
                                              borderRadius: BorderRadius.circular(60.0),
                                              child: Icon(MdiIcons.squareEditOutline,color: AppColors.popUpBlueColor,size: 20,),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),)
                              ],
                            ):Stack(
                              children: [
                                Container(
                                  height: 150,
                                  width:_width,
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Container(
                                        height: 120,
                                        width: 120,
                                        decoration: BoxDecoration(
                                          color: Colors.white,
                                          shape: BoxShape.circle,
                                          image: DecorationImage(
                                            fit: BoxFit.fill,
                                            image:  FileImage(_image!),
                                          ),
                                          border: Border.all(color: AppColors.white, width: 2.0),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                                Positioned(
                                  top: 60,
                                  right: 0,
                                  left: 100,
                                  bottom: 0,
                                  child: GestureDetector(
                                    onTap: (){
                                      _showChoiceDialog(context);
                                    },
                                    child: Container(
                                      height: 10,
                                      width: _width,
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          Container(
                                            height: 35,
                                            width: 35,
                                            decoration: BoxDecoration(
                                              color: AppColors.profiePicBackground,
                                              borderRadius: BorderRadius.circular(60),
        
                                              //border: Border.all(color: Colors.blue.shade900, width: 2.0),
                                            ),
                                            child: ClipRRect(
                                              borderRadius: BorderRadius.circular(60.0),
                                              child: Icon(MdiIcons.squareEditOutline,color: AppColors.popUpBlueColor,size: 20,),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),)
                              ],
                            )

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.