Flutter 개발속도 향상법(analysis_options.yaml, const)

김영진·2021년 4월 18일
3

Flutter 앱 개발 일기

목록 보기
7/31

목적

유튜브를 보다 플러터 개발 시 생산성을 높일 수 있는 방법을 보아 기록한다.

분석

프로젝트/analysis_options.yaml 생성

  • 띄어쓰기가 민감하므로 조심, 처음 시작시 띄어쓰기 두번
사용법

reference : https://dart-lang.github.io/linter/lints/

  analyzer:
    errors:
      prefer_const_declarations: error
      prefer_const_constructors: error
      missing_required_param: error

  linter:
    rules:
      prefer_const_declarations: true
      prefer_const_constructors: true
      missing_required_param: true

어떤 linter를 사용할지 다 일일이 찾아보는것은 비 효율적이다.

https://pub.dev/packages/pedantic

구글이 사용하는 linter
# If you use `package:pedantic/pedantic.dart`, add a normal dependency.
dependencies:
  pedantic: ^1.11.0

# Or, if you just want `analysis_options.yaml`, it can be a dev dependency.
dev_dependencies:
  pedantic: ^1.11.0
최신버전 사용시
include: package:pedantic/analysis_options.yaml
특정버전 사용시
include: package:pedantic/analysis_options.1.11.0.yaml

개발속도가 빨라지는 이유?

  1. const를 활용하여 컴파일 타임을 늘리고 런타임을 줄일 수 있다.
  2. required같은 예약어들의 에러를 런타임이 아니라 컴파일 타임에 알 수 있다.

결론

개발환경 셋팅의 중요성에 대해 다시한번 생각해보는 계기가 되었다.

profile
2021.05.03) Flutter, BlockChain, Sports, StartUp

0개의 댓글