inheritFromWidgetOfExactType 플러터(flutter)


InheritedWidget이나 bloc패턴을 사용하다보면 inheritFromWidgetOfExactType을 자주 사용하게 되는데요. 코드를 입력하면 줄이 쭉 가있는데 더 이상 지원을 안 하는 것 같습니다. 


해결 방법은 inheritFromWidgetOfExactType 대신 dependOnInheritedWidgetOfExactType으로 입력하면 됩니다.




  static StoriesBloc of(BuildContext context) {

    return (context.inheritFromWidgetOfExactType(StoriesProvider) as StoriesProvider).bloc;

  }

  static StoriesBloc of(BuildContext context) {

    return context.dependOnInheritedWidgetOfExactType<StoriesProvider>().bloc;

  }



예시코드



오늘도 즐거운 하루되세요~

  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기