In the provider
model I use context after await
It shows warning Do not use BuildContexts across async gaps
and I am unable to check with mounted because I use it in Provider
class. so what I should do to remove this warning? Any help would be appreciated thanks.
class SoloStartSiteScanningProvider extends ChangeNotifier {
FocusNode boxFocusNode = FocusNode();
FocusNode locationFocusNode = FocusNode();
Future checkBoxSealMatching(BuildContext context) async {
try {
var barcode = await _scanBoxBarcode();
if (barcode != "-1") {
if (boxFieldController.text == barcode) {
// Do not use BuildContexts across async gaps
FocusScope.of(context).requestFocus(locationFocusNode);
}
}
} catch (e) {
print(" coll lactaion scanning Exception=== $e");
}
}
}
CodePudding user response:
Try like this