Widget build(BuildContext context) {
return Image(image: AssetImage('graphics/background.png'));
}
Image(
image: AssetImage("location/of/image"),
)
flutter:
assets:
- assets/my_icon.png
- assets/background.png
*Note:-
Very important thing to note while using asset is that:
--> In "pubspec.yaml" file:-
line with code "uses-material-design: true"
and line with code " assets:"
should lie in same column
--> example:-
# the material Icons class.
uses-material-design: true //this line
# To add assets to your application, add an assets section, like this:
assets: // and this line (in same column)
- assets/
--> Don't be oversmart and give your image name too in assets like this:-
" assets:
- assets/onePiece"
This will cause error....(Believe it)....
[UIImage flutterImageWithName:@"icons/heart.png"];
flutter:
assets:
- graphics/background.png
flutter:
assets:
- directory/
- directory/subdirectory/