flutter pub 명령어

김은상·2022년 10월 13일
0

일반적으로 새로운 플러그인을 추가할 때

pubspec.yaml 파일을 직접 수정한 다음 flutter pub get 명령을 실행하는 것 같다.

get 말고도 add, remove, outdated, upgrade 같은 명령을 이용하면 pubspec.yaml 파일을 직접 수정하지 않아도 된다.

패키지를 많이 사용하거나, 내부 패키지 형태로 모듈화를 하는 경우에 이런 명령들은 더욱 도움이 된다.

터미널에 flutter pub -h 를 입력하면 아래와 같이 설명이 나온다.

  add         pubspec.yaml에 의존성을 추가한다.
  cache       Work with the Pub system cache.
  deps        패키지 의존성들을 출력한다.
  downgrade   플러터 프로젝트의 패키지들을 다운그레이드한다.
  get         플러터 프로젝트로 패키지들을 가져온다.
  global      Work with Pub global packages.
  login       Log into pub.dev..
  logout      Log out of pub.dev..
  outdated    업그레이드 가능한 패키지를 찾아준다.
  pub         Pass the remaining arguments to Dart's "pub" tool.
  publish     Publish the current package to pub.dartlang.org.
  remove      Removes a dependency from the current package..
  run         Run an executable from a package.
  test        Run the "test" package.
  upgrade     Upgrade the current package's dependencies to latest versions..
  uploader    Manage uploaders for a package on pub.dev.
  version     Pub의 버전을 출력한다.

몇 가지 명령은 패키지를 배포할 때 사용하는 것들도 있다.

주로 사용하는 명령은 아래와 같다.

#### 버전 확인
flutter pub version

#### 의존성 출력 (트리 형태로 출력한다.)
flutter pub deps

#### 의존성 추가 (자동으로 yaml 파일이 수정된다.)
flutter pub add [패키지 이름]

#### 의존성 제거 (자동으로 yaml 파일이 수정된다.)
flutter pub remove [패키지 이름]

#### 업그레이드가 필요한 플러그인을 찾아준다.
flutter pub outdated

#### 업그레이드가 가능한 플러그인을 업그레이드 한다.
flutter pub upgrade

#### 플러그인들을 사용할 수 있게 프로젝트로 가져온다.
flutter pub get
profile
Flutter 시작

0개의 댓글