readPlacesJsonFile function

Future<String?> readPlacesJsonFile()

Read the main places.json file.

Implementation

Future<String?> readPlacesJsonFile() async {
  try {
    final fp = await getPlacesFilePath();
    final url = await getFileUrl(fp);
    final (:accessToken, :dPopToken) = await getTokensForResource(url, 'GET');
    final r = await http.get(
      Uri.parse(url),
      headers: {
        'Accept': 'application/json, */*',
        'Authorization': 'DPoP $accessToken',
        'Connection': 'keep-alive',
        'DPoP': dPopToken,
      },
    );
    return r.statusCode == 200 ? r.body : null;
  } catch (_) {
    return null;
  }
}