프로젝트 생성
1. 'New Flutter Project' 클릭하여 프로젝트 생성
2. flutter SDK 파일 경로 설정
3. 프로젝트명 설정 ( * 띄어쓰기 없이 영어 소문자로 작성 / 띄어쓰기는 언더바로 대체 )
Git 연동
1. Git Repository 생성
2. Android Studio와 Git 계정을 연동한다
3. Android Studio의 터미널에 git init을 입력하여 프로젝트가 git의 관리에 들어가도록 설정한다
4. github 연동을 위한 첫번째 커밋을 하기 위해서 git add .와 git commit -m "feat: First Commit"을 터미널에 입력한다
5. github에 생성한 repository와 로컬 저장소를 연결하기 위하여 터미널에 아래와 같이 입력한다
git remote add origin 원격저장소주소.git로컬 저장소와 원격저장소(github) 연결 / origin = 원격저장소명 다른 이름도 가능git branch -M main기본 브랜치명을 main으로 지정git push -f origin main현재 브랜치와 명시된 원격 브랜치 기본 연결
6. 위 과정이 완료되면 다음과 같이 github repository에 파일들이 게시된다
참고
https://bada744.tistory.com/106
기타 설정
1. 한글에 뜨는 밑줄 끄기
상단 File > Settings > Editor > Inspections > 상단Profile을 Default로 선택 > Proofreading > Typo 부분을 체크해제
2. 린트 끄기
analysis_options.yaml 파일의 rules에 코드 네 줄 추가하여 린트를 끈다
* 린트: 소스 코드를 분석하여 프로그램 오류, 버그, 스타일 오류, 의심스러운 구조체에 표시(flag)를 달아놓기 위한 도구들
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
prefer_const_constructors: false
avoid_print: false
prefer_typing_uninitialized_variables: false
prefer_const_constructors_in_immutables: false
prefer_const_literals_to_create_immutables: false
main.dart 파일 수정
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
그리고 stless 입력후 tab 키를 누른 후 아래와 같이 수정
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Text('home')
);
}
}
이미지 경로 설정
/roots에 이미지를 담을 assets 폴더를 생성하고 pubspec.yaml 파일의 flutter(53줄)에 아래와 같이 경로를 추가한다
# The following section is specific to Flutter packages.
flutter:
assets:
- assets/
# 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
아래와 같이 입력하여 이미지 파일을 화면에 나타낼 수 있다
return MaterialApp(
home: Image.asset('assets/image.jpg')
);
구글 폰트 설정
설치
터미널에 아래와 같이 입력하여 구글 폰트를 설치한다
flutter pub add google_fonts
사용법
폰트를 사용하고 싶은 파일의 상단에 구글 폰트 패키지를 import하고
import 'package:google_fonts/google_fonts.dart';
아래와 같이 사용한다
Text(
'Hello!',
style: GoogleFonts.bebasNeue(
fontSize: 52,
)
)
참고