before

List<String> datas;
final tags = record['tags'];
  if (tags != null) {
     datas = tags;
  }

console

E/flutter (32539): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception:
type 'List<dynamic>' is not a subtype of type 'List<String>'


solution

List<String> datas;
final tags = record['tags']?.cast<String>() ;
  if (tags != null) {
     datas = tags;
  }
profile
𝙸 𝚊𝚖 𝚊 𝚌𝚞𝚛𝚒𝚘𝚞𝚜 𝚍𝚎𝚟𝚎𝚕𝚘𝚙𝚎𝚛 𝚠𝚑𝚘 𝚎𝚗𝚓𝚘𝚢𝚜 𝚍𝚎𝚏𝚒𝚗𝚒𝚗𝚐 𝚊 𝚙𝚛𝚘𝚋𝚕𝚎𝚖. 🇰🇷👩🏻‍💻

2개의 댓글

comment-user-thumbnail
2020년 7월 30일

http 통신할때 모델을 리스트로 만들어줄때 엄청많이나는 오류였는데
var parsed = jsondcode(res.body).cast<Map<String,dynamic>>(); 이런식으로하니 잘되네요 감사합니다.

1개의 답글