barcode_scanner/lib/pages/operation/reception/reception_search_page_model.dart
mandreshope 3d5d013763 enhance: Improves search by ignoring case
Updates the reception name search to be case-insensitive. This enhances
usability by ensuring search results are found regardless of the
capitalization used in the query.

Also increments the application version.
2025-08-05 13:50:02 +03:00

41 lines
1.3 KiB
Dart

import 'package:e_scan/backend/api/api_calls.dart';
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final receptionSearchPageModelProvider =
StateNotifierProvider.autoDispose<
ReceptionSearchPageModel,
AsyncValue<List<StockPickingRecordEntity>>
>((ref) {
return ReceptionSearchPageModel();
});
class ReceptionSearchPageModel
extends StateNotifier<AsyncValue<List<StockPickingRecordEntity>>> {
/// Constructor initializes the TaskRepository using the provider reference.
ReceptionSearchPageModel() : super(const AsyncValue.loading());
Future<void> allByName({required String name}) async {
try {
state = AsyncValue.loading();
final res = await ApiCalls.getAllStockPiking();
res.when(
(data) async {
final founds = data
.where(
(e) =>
e.name?.toLowerCase().contains(name.toLowerCase()) == true,
)
.toList();
state = AsyncValue.data(founds);
},
(error) {
state = AsyncValue.error(error, StackTrace.current);
},
);
} catch (e) {
state = AsyncValue.error(e, StackTrace.current);
}
}
}