如何减少API加载时间的波动

时间:2019-11-08 05:03:28

标签: api flutter dart

我正在使用rest api来显示数据,但是对于api加载,我需要花费更多时间才能减少抖动时间。

      Future getData0() async {

    Future<SharedPreferences> _prefs = SharedPreferences.getInstance();

    final SharedPreferences prefs = await _prefs;

    var receivedToken = "Bearer " + prefs.getString("BearerToken");

    var receivedstoreid=prefs.getString("store_id");

    http.Response res = await http.get(
        "http://Domainname.com/api/rest/cart",
      headers: {
        'Authorization': receivedToken,
        'X-Oc-Store-Id': receivedstoreid,

      },
    );


    Map mapRes = jsonDecode(res.body);
    print('Response from server: $mapRes');

    get_cart_item = GetCart.fromJson(mapRes);
    print(get_cart_item.toJson());

我这样调用get和post api。

0 个答案:

没有答案