getDeliverMethod method

Future<List<Lookup>> getDeliverMethod()

Implementation

Future<List<Lookup>> getDeliverMethod() async {
  lookupDeliveryMethod.value = ViewData.loading();
  update();

  final result = await lookupService.searchLookup(
    lookupCd: 'DELIVERY_TYPE',
    param: {'name': "DELIVERY_TYPE"},
  );

  return result.fold(
    (failure) {
      lookupDeliveryMethod.value = ViewData.error(message: failure.message);
      onError?.call(failure.message);
      update();
      throw Exception(failure.message);
    },
    (data) {
      if (data.isEmpty) {
        lookupDeliveryMethod.value = ViewData.empty();
        update();
        throw Exception('No delivery method found');
      } else {
        lookupDeliveryMethod.value = ViewData.loaded(data: data);
        update();
        return data;
      }
    },
  );
}