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

home2 게시판 Flutter 게시판 provider에서 Store2를 생성했는 오류가 뜹니다..

provider에서 Store2를 생성했는 오류가 뜹니다..

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

    조정민
    참가자

    Error: Could not find the correct Provider<Store1> above this Profile Widget

    This happens because you used a BuildContext that does not include the provider
    of your choice. There are a few common scenarios:

    - You added a new provider in your main.dart and performed a hot-reload.
    To fix, perform a hot-restart.

    - The provider you are trying to read is in a different route.

    Providers are "scoped". So if you insert of provider inside a route, then
    other routes will not be able to access that provider.

    - You used a BuildContext that is an ancestor of the provider you are trying to read.

    Make sure that Profile is under your MultiProvider/Provider<Store1>.
    This usually happens when you are creating a provider and trying to read it immediately.

    For example, instead of:

    `
    Widget build(BuildContext context) {
    return Provider<Example>(
    create: (_) => Example(),
    // Will throw a ProviderNotFoundError, because context is associated
    // to the widget that is the parent of Provider<Example>
    child: Text(context.watch<Example>()),
    ),
    }
    `

    consider using builder like so:

    `
    Widget build(BuildContext context) {
    return Provider<Example>(
    create: (_) => Example(),
    // we use builder to obtain a new BuildContext that has access to the provider
    builder: (context) {
    // No longer throws
    return Text(context.watch<Example>()),
    }
    ),
    }
    `

    If none of these solutions work, consider asking for help on StackOverflow:

     

    도대체 이유가 뭔가요... 

    stroe1은 되는데 store2는 왜 안되죠?

    #29088

    codingapple
    키 마스터

    store2를 등록을 안했거나 context를 이상한걸 썼나봅니다 

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