简体   繁体   中英

i am trying to run my app and i am getting this error message?

I am using flutter in android studio. All my Dart files contain no errors, my images file has an avatar image named avatar.png but I get this error:

No file or variants found for asset: images/avatar.png.

Is my images file not in the right folder? If yes where should I paste it in my app project files?

flutter:

uses-material-design: true
# To add assets to your application,
# add an assets section,
# like this: assets: -images / avatar.png# - images / a_dot_ham.jpeg
Widget logo() {
    return new Hero(
        tag: 'hero',
        child: new CircleAvatar(
            backgroundColor: Colors.blue,
            radius: 80.0,
            child: Image.asset('images/avatar.png'),
        ),
    );
}

Error detected in pubspec.yaml: No file or variants found for asset: images/avatar.png.

Error: Failed to build asset bundle

Have you taken a look at the Flutter documentation for images ?

You are to place all resources (eg images) in an assets (in your case, images ) folder in the root directory and specify it in the pubspec.yaml file.

Also take a look at the Image constructor.

Please Check Your Avtar.png file in assets folder think you forgot or Remove that file..

Block quote

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM