createInstance method
Creates a new instance on the native side with the specified modelName
,
threshold
, and bufferCnt
.
If this instance is marked as the first instance ([isFirstInstance] == true
),
the method will also start the foreground service.
Returns true
when successful.
Implementation
Future<bool> createInstance(
String modelName,
double threshold,
int bufferCnt,
) async {
await _methodChannel.invokeMethod('createInstance', {
'instanceId': instanceId,
'modelName': modelName,
'threshold': threshold,
'bufferCnt': bufferCnt,
});
// If this is the first instance, start the foreground service (Android).
if (isFirstInstance) {
isFirstInstance = false;
await startForegroundService();
}
return true;
}