
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.
41 lines
1.3 KiB
Dart
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);
|
|
}
|
|
}
|
|
}
|