Recommanded Free YOUTUBE Lecture: <% selectedImage[1] %>

Contents

터미널 기반 개발 환경 설정

지금까지 만들어본 개발 환경은 아래와 같다.
  1. Android Studio 기반 Flutter 개발환경
  2. Visual Studio Code 기반 개발환경
이번에는 터미널 기반으로 개발 환경을 세팅해보려한다. Vim 기반으로 세팅해보려는게 이유다. 굳이 왜 vim 기반이냐고 하면, 너무 가볍기 때문이다.

Dart SDK와 Flutter 프레임워크는 이미 설치를 끝낸 상태이므로 곧바로 프로젝트를 만들어보기로 했다.

Flutter 프로젝트 만들기

create명령으로 helloworld 프로젝트를 만들었다.
# flutter create hello
Creating project helloworld...
  helloworld/android/settings.gradle (created)
  helloworld/android/gradle/wrapper/gradle-wrapper.properties (created)
  helloworld/android/gradle.properties (created)
  helloworld/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (created)
// 생략 ......
Running "flutter pub get" in helloworld...                          6.6s
Wrote 66 files.

All done!
[✓] Flutter is fully installed. (Channel beta, v1.7.8+hotfix.3, on Linux, locale ko_KR.UTF-8)
[✓] Android toolchain - develop for Android devices is fully installed. (Android SDK version 29.0.0)
[✓] Android Studio is fully installed. (version 3.4)
[!] Connected device is not available.

Run "flutter doctor" for information about installing additional components.

In order to run your application, type:

  $ cd helloworld
  $ flutter run

Your application code is in helloworld/lib/main.dart.
프로젝트가 만들어졌다. Connected device is not available경고가 뜨긴 했지만, 아직 디바이스 실행전이니 중요한 문제는 아니다. main 함수를 포함한 코드는 helloworld/lib/main.dart 라고 친절하게 안내해준다.

Flutter 프로젝트 실행하기

프로젝트 디렉토리로 이동 run 명령으로 프로젝트를 실행해본다.
# cd helloworld 
# flutter run
No connected devices.
연결 할 수 있는 디바이스가 없다고 에러가 떨어진다. doctor 명령으로 진단해보자.
# flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.7.8+hotfix.3, on Linux, locale ko_KR.UTF-8)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Android Studio (version 3.4)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.
devices 명령으로 연결된 디바이스 목록을 확인해보자.
flutter devices
No devices detected.

Run 'flutter emulators' to list and start any available device emulators.

Or, if you expected your device to be detected, please run "flutter doctor" to diagnose potential issues, or visit https://flutter.dev/setup/ for
troubleshooting tips.

emulators 명령으로 사용 할 수 있는 디바이스 리스트를 확인 할 수 있다.
# flutter emulators
3 available emulators:

Pixel_2_API_28   • pixel_2 • Google • Pixel 2 API 28
Pixel_2_API_29   • pixel_2 • Google • Pixel 2 API 29
flutter_emulator • pixel   • Google

To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.

You can find more information on managing emulators at the links below:
  https://developer.android.com/studio/run/managing-avds
  https://developer.android.com/studio/command-line/avdmanager
3개의 애뮬레이터를 발견했다. 이중 사용 할 수 있는 에뮬레이터는 Pixel_2_API_28(왠일인지 Q버전은 에러때문에 사용 할 수 없다.) 이다. 애뮬레이터를 실행했다.
# flutter emulators --launch Pixel_2_API_28

devices 명령으로 디바이스 연결을 확인 할 수 있다.
# flutter devices
1 connected device:

Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 9 (API 28) (emulator)

이제 애플리케이션을 실행해보자.
# flutter run

애플리케이션을 실행하고 나면 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".메시지를 볼 수 있다. r, R 키를 눌러서 코드 변경내용을 즉시 확인 할 수 있다.

핫 리로드(Hot reload)를 이용하면 개발시간을 크게 단축시킬 수 있을 것 같다.

자동완성

자동완성 기능까지 추가하면 쓸만한 개발환경을 완성할 수 있을 것 같다. 일단은 NeoVim과 coc(Conquer Of Completion)을 이용해서 환경을 만들었다.

자세한 내용은 NeoVIM과 Coc를 이용한 개발환경 구축문서를 참고하자.