barcode_scanner/lib/pages/operation/reception/reception_details_page_model.dart
your-name da2c3ac4f0 enhance: Enhances scanner UI and integrates toast notifications
Integrates the `toastification` package to provide clear and non-intrusive user feedback for operations like product not found.

Refactors the reception scan page UI by extracting reusable widgets for the scan information text, the scan box, and the flash button. This improves code organization and readability.

Switches the data source for reception details from API calls to the local ObjectBox database, improving performance and enabling offline access for this specific data.

Corrects the display of scanned product information to show the barcode instead of a generic ID.

Updates `go_router` to version 16.0.0.
2025-07-30 19:35:43 +03:00

41 lines
1.4 KiB
Dart

import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
import 'package:e_scan/backend/objectbox/objectbox_manager.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'reception_details_page_model.freezed.dart';
final receptionDetailsPageModelProvider =
StateNotifierProvider.autoDispose<
ReceptionDetailsPageModel,
ReceptionDetailsPageState
>((ref) {
return ReceptionDetailsPageModel();
});
class ReceptionDetailsPageModel
extends StateNotifier<ReceptionDetailsPageState> {
ReceptionDetailsPageModel() : super(const ReceptionDetailsPageState());
Future getReceptionById({required int id}) async {
try {
final stockPickingRecords = objectboxManager.store
.box<StockPickingRecordEntity>();
state = state.copyWith(loading: true);
final entity = stockPickingRecords.get(id);
state = state.copyWith(loading: false, reception: entity);
} catch (e) {
state = state.copyWith(loading: false);
}
}
}
@freezed
abstract class ReceptionDetailsPageState with _$ReceptionDetailsPageState {
const factory ReceptionDetailsPageState({
StockPickingRecordEntity? reception,
@Default(false) bool loading,
}) = _ReceptionDetailsPageState;
}