checkAndRun method
Check if application can run and perform initialization.
Returns:
- true: Application can start
- false: Another instance is already running
Implementation
@override
Future<bool> checkAndRun({required FlutterAloneConfig config}) async {
try {
final map = config.toMap();
final result = await _channel.invokeMethod<bool>(
'checkAndRun',
map,
);
// In debug mode, assert that the platform returned a valid result
assert(result != null,
'flutter_alone: platform returned null from checkAndRun');
// In release mode, treat null as "cannot run" (safety-first)
return result ?? false;
} on PlatformException catch (e) {
throw AloneException(
code: e.code,
message: e.message ?? 'Error checking application instance',
details: e.details,
);
}
}