flutter version 2.5.2 기준으로 작성됨
안될 때 체크사항
도 확인해 볼 것!assets
와 images
⭐중요⭐ 탭/띄어쓰기를 잘 신경 쓸 것!
flutter:
uses-material-design: true
assets:
- assets/profile/
- images/
assets:
띄어쓰기 2칸- assets/...
,- images/
띄어쓰기 4칸Image.asset('assets/profile/yellow.jpeg'),
Image.asset('images/green.png'),
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('assets-and-images'),
),
body: ListView(
children: <Widget>[
Image.asset('assets/profile/yellow.jpeg'),
Image.asset('images/green.png'),
],
),
),
);
}
}
flutter pub get
후 앱 다시 시작