searchProducts method

Future<List<ProductInfo>> searchProducts({
  1. required String searchText,
  2. int? limit,
  3. int offset = 0,
  4. int? productType,
  5. String? sortColumn,
  6. String? sortType,
})

Products search by product name.

Use limit and offset to paginate the result.

Valid values for sortType are: 'asc' and 'desc'

Implementation

Future<List<ProductInfo>> searchProducts({
  required String searchText,
  int? limit,
  int offset = 0,
  int? productType,
  String? sortColumn,
  String? sortType,
}) async {
  final result = await _repository.searchProductsRequest(
    sessionId,
    accountInfo.intAccount,
    searchText,
    limit,
    offset,
    productType ?? invalidIntValue,
    sortColumn,
    sortType,
  );

  List<ProductInfo> products = [];

  result.when(
    (data) {
      products = data;
    },
    (error) => throw error..methodName = 'searchProducts',
  );

  return products;
}