deleteAccount method

Future<void> deleteAccount(
  1. int index
)

Delete account specified by its index in the list

Implementation

Future<void> deleteAccount(int index) async {
  try {
    int accId = _accounts[index].myAccId;
    await SiprixVoipSdk().deleteAccount(accId);

    _accounts.removeAt(index);

    if(_selAccountIndex! >= length) {
      _selAccountIndex = _accounts.isEmpty ? null : length-1;
    }

    notifyListeners();
    _raiseSaveChanges();
    _logs?.print('Deleted account accId:$accId');

  } on PlatformException catch (err) {
    _logs?.print('Can\'t delete account: ${err.code} ${err.message}');
    return Future.error((err.message==null) ? err.code : err.message!);
  }
}