I have as simple river pod provider (for testing) but it is not calling the compeltion callbacks.
I am using below package to scan barcode with camera and once barcode is retrived I am calling the provider funtion.
pub: ai_barcode_scanner: ^5.1.1
MobileScanner(
onDetect: (p0) {
if (p0 == null) {
return;
}
if (p0.barcodes == null || p0.barcodes.isEmpty) {
return;
}
final barcode = p0.barcodes.first.rawValue.toString();
ref.read(boredSuggestionProvider).when(data: (d) {
print(d);
}, error: (e, s) {
print(e);
}, loading: () {
print("loading");
}); // this is a test provider but same issue with this as well.
},
...
@Riverpod(keepAlive: true)
Future<String> boredSuggestion(BoredSuggestionRef ref) async {
final json = {
'activity': 'Go to the gym and do some exercise.',
'qwe': 'asdsd'
};
return json['activity']! as String;
}
Only loading gets printed and data print function doesn’t get executed.