getDataNetwork method

Future<ResponseData> getDataNetwork(
  1. String userID,
  2. String packageName
)

Implementation

Future<ResponseData> getDataNetwork(String userID, String packageName) async {
  try {
    String platformType = 'android';
    if (Platform.isIOS) platformType = 'ios';
    if (Platform.isMacOS) platformType = 'ios';

    final url =
        'https://firebasestorage.googleapis.com/v0/b/mnc-apps-libs.appspot.com/o/json%2F$userID%2F$packageName-$platformType?alt=media';
    final data = await http.get(Uri.parse(url));
    if (data.statusCode != 200)
      throw '[MNCAPPS] Error getting data for $userID with package name $packageName and platform type $platformType';

    final res = ResponseData.fromJson(data.body);

    return res;
  } catch (e) {
    rethrow;
  }
}