connectToServer static method
Implementation
static Future<Map> connectToServer({
required String username,
required String password,
required String appType,
}) async {
final url = Uri.parse(
"https://apn1.leewayapi.in/connect_user.php?username=$username&password=$password&App=$appType");
try {
final response = await http.get(url);
if (response.statusCode == 200) {
Map responseData = jsonDecode(response.body);
print("responseData ======>$responseData");
await MessageService().saveUsername(username);
// print("Username saved in connectToServer:========== $username");
return responseData;
} else {
throw Exception("Error: ${response.statusCode}");
}
} catch (e) {
debugPrint("Failed to connectToServer: ====>$e");
rethrow;
}
}