首页 > 解决方案 > I/flutter:FormatException:输入意外结束(在字符 1 处)

问题描述

I/flutter (28194): 错误是: FormatException: Unexpected end of input (at character 1)


 Future<void> addRateOrder(String comment, int rate, String orderId) async{
     Map<String, dynamic> rateOrderData = Map();
     rateOrderData['Comment'] = comment;
     rateOrderData['Rate'] = rate.toString();
     try{
      String url = Urls.buildRateOrder(orderId);
      final response =  await retry(
         ()=>http.post(url,         
                  body: rateOrderData)
                  .timeout(Duration(seconds: 5)),
                  retryIf: (e)=> e is SocketException || e is TimeoutException
                  );
                  final responseData =json.decode(response.body);
                  print(responseData);

     }catch(error){
       print('error is: $error');
       throw error;
     }
    }

标签: flutterpostdartwidgetprovider

解决方案


有时它是由于在您的代码中两次向同一个 Api 发送相同的请求而发生的


推荐阅读