강의

멘토링

커뮤니티

Inflearn Community Q&A

wyrdism0050's profile image
wyrdism0050

asked

[Code Factory] [Intermediate] Flutter Real Practice! State Management, Cache Management, Code Generation, GoRouter, Authentication Logic, etc. Essential Skills to Become an Intermediate!

Finalize the payment function

이 경고는 어떻게하면 없어지나요?

Written on

·

380

0

Screen Shot 2022-10-03 at 19.00.54.png

찾아보니 mounted 확인하고 리턴시켜라는데
mounted가 존재하지 않네요.

무시해도 상관없겠지만 개인적으로 노란줄 뜨는거 싫어해서 해결 방법이 있다면 알고 싶습니다.

 

하이브리드 앱Flutter

Answer 2

0

Geonwoo Jeong님의 프로필 이미지
Geonwoo Jeong
Questioner

답변감사합니다.

context.mounted가 없어서 찾아봤는데

StatefulWidget에는 그냥 mounted로 존재하고

StatelessWidget에는 없네요

https://github.com/flutter/flutter/issues/111488

이 이슈가 머지 되었으니 다음 릴리즈 때에는 반영될 것 같습니다

마스터 채널로 변경하니 나오네요

0

codefactory님의 프로필 이미지
codefactory
Instructor

안녕하세요.

프레임워크나 언어 경고는 아니고 린트 경고인데 제 생각에는 큰 의미가 있는 사항은 아닌걸로 보여집니다. 실제로 async 갭을 두고 꼭 실행해야만 하는 기능들이 없지 않아서요. Experimental 상황이라 나중에 없어질수도 있습니다.

린트경고를 없애는 방법은 context 마운팅이 됐는지 확인을 하는방법입니다.

void onButtonTapped() async {
  await Future.delayed(const Duration(seconds: 1));

  if (!context.mounted) return;
  Navigator.of(context).pop();
}

 

아래 공식 링크에서도 확인하실 수 있습니다.

https://dart-lang.github.io/linter/lints/use_build_context_synchronously.html

wyrdism0050's profile image
wyrdism0050

asked

Ask a question