import 'package:flutter_secure_storage/flutter_secure_storage.dart'; /// Remembers scooter PINs in platform secure storage (Android Keystore backed /// storage, iOS Keychain), keyed by the BLE peripheral id. /// /// The peripheral id is not a permanent scooter identity (see ScooterDevice). /// Once the Apollo UID is read over AT+UID? this should key by that instead. class PinStore { PinStore([FlutterSecureStorage? storage]) : _storage = storage ?? const FlutterSecureStorage(); final FlutterSecureStorage _storage; String _key(String deviceId) => 'pin:$deviceId'; Future read(String deviceId) async { try { return await _storage.read(key: _key(deviceId)); } catch (_) { return null; } } Future save(String deviceId, String pin) => _storage.write(key: _key(deviceId), value: pin); Future forget(String deviceId) => _storage.delete(key: _key(deviceId)); }