urRunBridgeStatic function
dynamic
urRunBridgeStatic(})
Implementation
dynamic urRunBridgeStatic(Zone? zone, Function? f,
String context,
dynamic Function(Function) func, {
dynamic defValue = null,
bool nonnullable = false,
bool multiApplicationCheck = false,
bool reportError = true,
}) {
if (f == null || zone == null) {
try {
throw Exception("zone is null, ${context}");
} catch (e, stack) {
UnitRCError.report(
e: e, stack: stack, context: context, reportError: reportError);
if (nonnullable) {
rethrow;
}
}
return defValue;
}
final block = () {
if (multiApplicationCheck) {
if (!UnitRCApplication.isApplicationValid()) {
try {
throw Exception(
"invalid application: ${UnitRCApplication
.getCurrApplication()}, ${context}");
} catch (e, stack) {
UnitRCError.report(
e: e, stack: stack, context: context, reportError: reportError);
if (nonnullable) {
rethrow;
}
}
return defValue;
}
}
try {
return func(f);
} catch (e, stack) {
UnitRCError.report(
e: e, stack: stack, context: context, reportError: reportError);
return defValue;
}
};
if (identical(Zone.current, zone)) {
return block();
} else {
return zone.run(() {
return block();
});
}
}