verify method

Future<Response> verify({
  1. required bool isOffline,
  2. String? request,
  3. String? url,
  4. String? assetPath,
})

Implementation

Future<Response> verify({
  required bool isOffline,
  String? request,
  String? url,
  String? assetPath,
}) async {
  try {
    if (isOffline && assetPath!.isNotEmpty) {
      return await verifyOffline(assetPath);
    } else if (!isOffline && url!.isNotEmpty) {
      // Parse request body and send as POST request
      dynamic requestData;
      if (request != null && request.isNotEmpty) {
        try {
          requestData = jsonDecode(request);
        } catch (e) {
          // If JSON decode fails, try to parse as string representation of map
          requestData = request;
        }
      }
      return await verifyOnlineWithData(url, requestData);
    } else {
      throw Exception(ConstantVariable.noDataProviderString);
    }
  } catch (error) {
    throw Exception(error.toString());
  }

}