• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Flutter 게시판 async await 말고 Future써야 할까요....

async await 말고 Future써야 할까요....

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #49517

    산딸기
    참가자
     
    setState가 너무 빨리 사라져서 에러가 납니다. 앞에 await붙이면 또 에러납니다. Future써야 한다면 중간에 코드 다 갈아 엎고 새로 작성해야 할까요... 위젯빌드 부분이요..
    
    
    setState() called after dispose(): _UploadState#355fe(lifecycle state: defunct, not mounted)
    This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
    The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
    This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose()
    타이머 넣어봤는데도 안됩니다.. 마운트를 체크하라고하는데 잘 모르겠습니다.
    
    onPressed: ()  async{
      Navigator.of(context).pop();
      Uint8List file = await pickImage(ImageSource.gallery);
      if (this.mounted) {
        setState(() {
          file1=file;
        });
      }
      await Image.memory(file1!);},로 수정했는데 이젠 이미지파일이 안보이네요..-_-;;;;isNotEmpty나 hasData로 조건문 쓰고 싶은데 앞에 뭐쓰고 점찍어야 하는지 몰겠습니다. 예)if(file.isNotEmpty)
    #49529

    codingapple
    키 마스터
    페이지 닫고나서 setState어쩌구 해서 그런게아닐까요
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠