AssetImage is not displaying image in flutter app

前端 未结 9 636
野趣味
野趣味 2021-01-13 00:33

image not displaying in flutter app. But I got some errors in debug console.

I/FlutterActivityDelegate(22603): onResume setting current activity to this
I/Fl         


        
9条回答
  •  一个人的身影
    2021-01-13 00:39

    There may be two issues:

    1.) Either you pubspec.yaml file is not having proper indention. Attaching snippet for reference.

    flutter:  
      uses-material-design: true   
      assets:   
        - assets/
    

    - assets/ will consider all the images in the directory.

    2.) If you are using .jpg image then please change it to .jpeg wherever you are calling it.

    Attaching the snippet for you reference

    class _UserLoginState extends State {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Stack(
            children: [
              Image(image: AssetImage("assets/christmas.jpeg"),
              fit: BoxFit.cover,
            ],
          )
        );
      }
    } 
    

提交回复
热议问题