inflearn logo
Course

Course

Instructor

vince's Posts

vince vince

@vince

Students
-
Reviews
-
Course Rating
-

Posts 2

Q&A

fetchData()

쓰시는 api가 강의랑 다른거같네요. 의도하신거라면, double.tryParse(str)로 대체할 수 있습니다 ( tryParse dart 문서 ) 이 메소드는 유효하지 않은 입력이 들어오면, 즉 파싱 실패하면 예외를 던지는 대신 null을 반환합니다 no2Value = double.tryParse(json['no2Value']) ?? 0.0; 이렇게 쓰시면 될 듯 합니다 no2Value = double.tryParse(json['no2Value'] ? '0') ?? 0.0 빈 값일때 채우는 로직까지 추가하면 위와 같이 쓰시면 될 듯 합니다

Likes
0
Comments
2
Viewcount
661