deleteContactDialogue function
Future
deleteContactDialogue({
- required BuildContext context,
- required String value,
- required ContactInfoType type,
- required ContactProvider? provider,
deletes a secondary contact from an account
Implementation
Future<dynamic> deleteContactDialogue({
required BuildContext context,
required String value,
required ContactInfoType type,
required ContactProvider? provider,
}) async {
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
const String flag = 'retire_contact';
return AlertDialog(
backgroundColor: Theme.of(context).backgroundColor,
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(
retireMsg(value),
style: TextThemes.normalSize14Text(),
),
],
),
),
actions: provider!.checkWaitingFor(flag: flag) as bool
? <Widget>[
const SILPlatformLoader(),
]
: <Widget>[
TextButton(
key: confirmButtonKey,
onPressed: () async {
provider.contactUtils
.toggleLoadingIndicator(context: context, flag: flag);
final Map<String, dynamic> result =
await provider.contactUtils.retireSecondaryContact(
value: value,
isPhone: type == ContactInfoType.phone,
context: context,
flag: flag);
if (result['status'] == 'error') {
provider.contactUtils.toggleLoadingIndicator(
context: context, flag: flag, show: false);
Navigator.pop(context, <String, String>{
'status': 'error',
'message': retireFeedback(value, hasError: true),
});
return;
}
Navigator.pop(context, <String, String>{
'status': 'ok',
'message': retireFeedback(value),
});
},
child: Text(
'Confirm',
style: TextThemes.boldSize16Text(Colors.red),
),
),
TextButton(
key: cancelButtonKey,
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Cancel'),
),
],
);
},
);
}