setSubscriber method
Implementation
Future<bool> setSubscriber() async {
if (nameController.text.isEmpty) {
throw Exception("name is required");
}
if (profilepinController.text.isEmpty) {
throw Exception("profilepin is required");
}
try {
var data = await NetworkHandler.updateProfile(
subscribername: nameController.text,
dob: dobController.text,
profilePin: profilepinController.text,
picture: profileUrl,
gender: gender);
if (data.containsKey('errorcode')) {
debugPrint("profile pic neeed");
throw Exception(data['reason']);
}
var subscriberData = await NetworkHandler.getSubscriber();
debugPrint(subscriberData);
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString('subscriber_data', subscriberData.toString());
return true;
} catch (error) {
debugPrint("errror");
throw Exception(error.toString());
}
}