The getter 'displayName' was called on null. Receiver: null Tried calling: displayName 솔루션
소개
이 문제가 발생한 것은, 아래의 my_page_screen.dart
의 구현을 진행하고 있을 때
이 오류의 원인은 무엇입니까?
데이터의 취득이 끝나지 않은데 위젯이 작성되기 때문인지, Consumer에서 일시적으로 에러가 발생한다. . . 피 c. 라고 r. 코 m / y8 깡패 1V 9 — 고졸 프로그래머 겐토 (@gento34165638) May 17, 2021
데이터의 취득이 끝나지 않은데 위젯이 작성되기 때문인지, Consumer에서 일시적으로 에러가 발생한다. . . 피 c. 라고 r. 코 m / y8 깡패 1V 9 — 고졸 프로그래머 겐토 (@gento34165638) May 17, 2021
Provider에서 아직 값을 얻지 못했지만 Widget 그리기가 시작되었기 때문일 수 있습니다
"null"의 경우 조건을 추가합시다.
child: Column(
children: <Widget>[
Consumer<UserProvider>(builder: (context, model, child) {
final userData = model.userModels;
return userData == null
? Container()
: Row(
children: <Widget>[
Container(
child: Column(
children: <Widget>[
Consumer<UserProvider>(builder: (context, model, child) {
final userData = model.userModels;
return userData == null
? Container()
: Row(
children: <Widget>[
Container(
이 방법으로 ?
및 :
를 사용하여 위젯 표시를 조건에 따라 전환 할 수 있습니다!
이 경우 userData == null
그럼 빈 Container()
보기userData == null
그렇지 않으면 userData
를 사용하여 값 표시 Row()
return userData == null ? Container() : Row()
참고
Reference
이 문제에 관하여(The getter 'displayName' was called on null. Receiver: null Tried calling: displayName 솔루션), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kokogento/items/bdfc3fc9a6e7f3850831텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)