getAndroidApps static method

Future<List<App>> getAndroidApps(
  1. String id
)

Implementation

static Future<List<App>> getAndroidApps(String id) async {
  String? content = await Util._fetchUrl(
    "https://play.google.com/store/apps/developer?id=${id.replaceAll(" ", "+")}",
  );
  final List<App> apps = [];
  if (content != null) {
    int start = content.indexOf("AF_initDataCallback({key: 'ds:3',");
    start = content.indexOf("data:", start) + 5;
    final int end = content.indexOf(", sideChannel:", start);
    content = content.substring(start, end);
    for (dynamic item in jsonDecode(content)[0][1][0][22][0]) {
      item = item[0];
      apps.add(
        App(
          id: item[0][0],
          name: item[3],
          category: item[5],
          developerName: item[14],
          rating: double.tryParse(item[4][0]) ?? 0,
          imageUrl: item[1][3][2],
          url:
              "https://play.google.com/store/apps/details?id=np.com.dhirajsharma.football_score${item[0][0]}",
        ),
      );
    }
  }
  return apps;
}