import 'package:aves/services/common/services.dart'; import 'package:flutter/services.dart'; abstract class SecurityService { Future writeValue(String key, T? value); Future readValue(String key); } class PlatformSecurityService implements SecurityService { static const _platform = MethodChannel('deckers.thibault/aves/security'); @override Future writeValue(String key, T? value) async { try { await _platform.invokeMethod('writeValue', { 'key': key, 'value': value, }); return true; } on PlatformException catch (e, stack) { await reportService.recordError(e, stack); } return false; } @override Future readValue(String key) async { try { final result = await _platform.invokeMethod('readValue', { 'key': key, }); if (result != null) return result as T; } on PlatformException catch (e, stack) { await reportService.recordError(e, stack); } return null; } }