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

home2 게시판 Flutter 게시판 Provider 관련해서 질문드립니다

Provider 관련해서 질문드립니다

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

    최지문
    참가자

    강의 에서 나온대로 Store를 만들어서 Text() 같은 위젯에다가 넣을 경우에는 작동이 잘되지만 ,

    버튼이나 네이게이션바에 onpress 에 반응하여 프린트를 하거나 조건문의 조건으로 넣게 되면 다음과 같은 오류가 뜨는데 해결방법을 모르겠습니다.

    `

    Tried to listen to a value exposed with provider, from outside of the widget tree.

    This is likely caused by an event handler (like a button's onPressed) that called
    Provider.of without passing listen: false.

    To fix, write:
    Provider.of<Store>(context, listen: false);

    It is unsupported because may pointlessly rebuild the widget associated to the
    event handler, when the widget tree doesn't care about the value.

    The context used was: HomePage(dependencies: [_LocalizationsScope-[GlobalKey#e3db6], _InheritedProviderScope<Store2?>], state: _HomePageState#5c9be)
    'package:provider/src/provider.dart':
    Failed assertion: line 274 pos 7: 'context.owner!.debugBuilding ||
    listen == false ||
    debugIsInInheritedProviderUpdate'

    `

    #24182

    codingapple
    키 마스터

    state바뀔 때 재렌더링필요없는 곳에선 .watch 쓰면 뭐라고 합니다 

    .read로 바꾸면 됩니다

     

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 호 / 개인정보관리자 : 박종흠