loginSQL method

Future<BaseUserModel?> loginSQL({
  1. required String phone,
  2. required String uidPhone,
  3. bool formatJson = false,
})

Implementation

Future<BaseUserModel?> loginSQL({
  required String phone,
  required String uidPhone,
  bool formatJson = false,
}) async {
  if (uidPhone.isEmpty || phone.isEmpty) return null;
  try {
    var response = await SQLService.execute(
      'sp_getLogin',
      params: {'phone': phone, 'uidPhone': uidPhone},
      formatJson: formatJson,
    );
    var data = Methods.getList(response, 'info');
    if (data.isEmpty) return null;
    if (data[0].isEmpty) return null;
    var id = Methods.getInt(data[0], 'ID', defaultValue: 0);
    if (id < 1) return null;
    if (kDebugMode) {
      print('$runtimeType loginSQL with phone: $phone, id: $id');
    }
    Common.uid = id;
    return BaseUserModel(data[0]);
  } catch (e) {
    handelException(e, subTitle: 'loginSQL');
    return null;
  }
}