小编Joh*_*nny的帖子

需要“List<dynamic>”类型的值,但得到“_JsonMap”类型之一

当我尝试 json 解码时,出现错误 Expected a value of type 'List', but getting one of type '_JsonMap'

我的代码:

  static Future<Response<Localizacao>> getLocalizacao(String cep) async {
    await Future.delayed(Duration(milliseconds: 200));
    try {
      Map<String, String> headers = {
        'Authorization': 'Token token=9e034db1f315356f30'};
      String protocol = 'https://cors-anywhere.herokuapp.com/';
      String uri =
          'https://www.cepaberto.com/api/v3/cep?cep=' + cep;
      final endpoint = "&format=json";
      String url = protocol + uri + endpoint;

      final response = await http.get(url, headers: headers);

      if (response.statusCode == 200) {

        final json = response.body;

        List list = (jsonDecode(json) as List<dynamic>) ; …
Run Code Online (Sandbox Code Playgroud)

api dart flutter flutter-web

10
推荐指数
1
解决办法
3万
查看次数

标签 统计

api ×1

dart ×1

flutter ×1

flutter-web ×1