onFetchComplete method
dynamic
onFetchComplete(
- String serviceName, {
- bool closeDialog = true,
- String? modelName,
})
Implementation
onFetchComplete(String serviceName,
{bool closeDialog = true, String? modelName}) async {
int i = 0;
Timer.periodic(const Duration(seconds: 1), (timer) async {
i++;
var value = await watchServiceCompleted(serviceName);
var fetchValue = await watchFetchCompleted(serviceName);
if (value.first['CompleteStatus'] == 1) {
timer.cancel();
if (onFetchCompleted != null) {
onFetchCompleted!('all fetch completed', 0);
}
if (closeDialog) {
await pdlg!.hide();
}
} else {
//print("Timer counter:" + i.toString());
if (fetchValue != null && fetchValue.length != 0) {
if (fetchValue.first["Success"] == 1) {
if (onFetchCompleted != null)
onFetchCompleted!(fetchValue.first["TableName"],
fetchValue.first["TotalRecord"]);
} else if (fetchValue.first["Success"] == 4) {
if (onFetchFailed != null)
onFetchFailed!(fetchValue.first["TableName"]);
}
}
if (i > 500) {
timer.cancel();
if (closeDialog) {
await pdlg!.hide();
}
}
}
});
}