login method
Implementation
Future<Map<String, dynamic>?> login(String username, String password) async {
final response = await http.post(
Uri.parse('$webbaseUrl/api/ibl/v1/authentication/login/'),
body: {'username': username, 'password': password, 'mobile': '1'},
);
var data = json.decode(response.body);
// Extracting the token from the redirect_uri field in the response
String? redirectUri = data['redirect_uri'];
if (redirectUri != null) {
String? token = Uri.parse(redirectUri).queryParameters['token'];
if (token != null) {
return {'token': token}; // Return the token as a JSON object
}
}
return data; // Return null if redirectUri is not in the response or token is not found
}