startSafeAreaObserver static method
Implementation
static Future<void> startSafeAreaObserver(SafeAreaCallback callback) async {
if (!initialized) {
await _injectJs(); // ✅ Wait until JS is fully available
initialized = true;
}
final safeAreaMonitor = js.context['SafeAreaMonitor'];
if (safeAreaMonitor == null) {
throw Exception('SafeAreaMonitor JS object not found');
}
js.context.callMethod('SafeAreaMonitor.startSafeAreaObserver', [
js.allowInterop((num bottomInset) {
callback(bottomInset.toDouble());
}),
]);
listening = true;
}