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> >((ref) { return ReceptionSearchPageModel(); }); class ReceptionSearchPageModel extends StateNotifier>> { /// Constructor initializes the TaskRepository using the provider reference. ReceptionSearchPageModel() : super(const AsyncValue.loading()); Future 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); } } }