Dart, does creating two different http requests over one http request improve performance? How does it increase?

Viewed 20

I am sending request to different APIs in one method

My method is as follows;

  final apiGateway = _global.apiGateway;

  Uri endpointUri(Endpoint endpoint, String location, {String? query = ''}) {
    return Uri.parse('$apiGateway${_path[endpoint]}$location$query');
  }

  final Map<Endpoint, String> _path = {
    Endpoint.identity: _global.identityUri,
    Endpoint.global: _global.globalUri,
    Endpoint.social: _global.socialUri,
  };

  Future<Response> fetchData(
    Endpoint endpoint,
    String location, {
    String? query = '',
  }) async {
    String accessToken = await _services.sharedPref.getString("accessToken");

    var headers = {
      "accept": "application/json",
      "content-type": "application/json",
      "authorization": 'Bearer $accessToken',
    };

    final uri = endpointUri(endpoint, location, query: query);

    return http.get(uri, headers: headers);
  }

How would my performance be affected if I didn't do this in one method, but made two separate methods and two separate get requests? would the single method have any effect on remembering the Flutter's get request?

0 Answers
Related