Flutter 에러 해결법 모음

바둑이·2021년 8월 30일

제가 개인적으로 Flutter를 사용하면서 발생한 에러를 순서에 상관없이 적는 곳입니다... 가끔씩 찾기 귀찮아서 모아놓는 것들입니다.

1.Cannot run with sound null safety, because the following dependencies don't support null safety

-Vscode 작성시 : 사용자 설정 -> "Flutter run additional args" 검색 후
--no-sound-null-safety 추가

-Android studio : Run -> Edit Configurations -> Additional run args에
--no-sound-null-safety 추가

2.Try making the call conditional (using '?.') or adding a null check to the target ('!').

ex1)
VoidCallback tap; -> VoidCallback? tap;
String text; -> String? text;
int index; -> int? index;
double width; -> double? width;
bool answerState; -> bool? answerState;

ex2) e.data()['myFieldOne'] -> (e.data() as dynamic)['myFieldOne'] or widget.width 0.048 -> (widget.width as dynamic) 0.048

3.type 'A' is not a subtype of type 'B'

ex1) final List< String >authors = json['authors']
에러내용 : type 'List< dynamic >' is not a subtype of type 'List< String >'
=> final List< String > authors = json['authors']?.cast< String >()

profile
안녕하세용('<')/

0개의 댓글