import 'dart:async'; import '../../../fly/state/settings_overlay.dart'; /// How long a written camera setting may stay unconfirmed before the HUD /// shows the camera's own value again. const Duration cameraSettle = Duration(seconds: 3); /// Writes one camera (or gimbal) setting the way every camera-menu row does /// (plan P4): show [pending] at once, send, roll back with [onError] if the /// component refuses, and drop the pending value after [cameraSettle] in any /// case — by then it has reported the new value (which replaces it) or ignored /// the write (and the row snaps back to what it really is). Future writeCameraSetting( SettingsOverlay camera, { required String label, required Map pending, required Future Function() send, required void Function(String label, Object error) onError, }) async { camera.setPending(pending); try { await send(); } catch (e) { camera.dropPending(pending.keys); onError(label, e); return; } Timer(cameraSettle, () => camera.dropPending(pending.keys)); }