Image : Image 위젯은 서버에 있는 이미지를 사용하는 네트워크 이미지와 앱에 저장된 이미지를 사용하는 AssetImage가 있습니다.
1. 네트워크 이미지 : image.network
네트워크 이미지는 말 그대로 서버에 저장되어 있는 이미지를 보여주는 방식으로 앱 용량을 줄일 수 있는 방법이다.
home: Scaffold(
body: Image.network('해당 경로')
),
2. 로컬 이미지: AssetImage
플러터에서 로컬 이미지를 앱에 보여주기 위해서는 assets폴더가 필요하고 assets폴더의 이미지를사용하기 위해서는 pubspec.yaml파일을 수정해야한다.
pubspec.yaml 파일 assets 경로설정
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/img/