diff options
| author | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
|---|---|---|
| committer | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
| commit | 449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch) | |
| tree | c131c3528c4d517f56e19b854a7453fedb097d40 /lib/services/security_service.dart | |
| download | aves-src-master.tar.gz aves-src-master.zip | |
Diffstat (limited to 'lib/services/security_service.dart')
| -rw-r--r-- | lib/services/security_service.dart | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/services/security_service.dart b/lib/services/security_service.dart new file mode 100644 index 0000000..5cc1d65 --- /dev/null +++ b/lib/services/security_service.dart @@ -0,0 +1,40 @@ +import 'package:aves/services/common/services.dart'; +import 'package:flutter/services.dart'; +import 'package:aves/services/common/channel.dart'; + +abstract class SecurityService { + Future<bool> writeValue<T>(String key, T? value); + + Future<T?> readValue<T>(String key); +} + +class PlatformSecurityService implements SecurityService { + static const _platform = AvesMethodChannel('deckers.thibault/aves/security'); + + @override + Future<bool> writeValue<T>(String key, T? value) async { + try { + await _platform.invokeMethod('writeValue', <String, dynamic>{ + 'key': key, + 'value': value, + }); + return true; + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); + } + return false; + } + + @override + Future<T?> readValue<T>(String key) async { + try { + final result = await _platform.invokeMethod('readValue', <String, dynamic>{ + 'key': key, + }); + if (result != null) return result as T; + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); + } + return null; + } +} |
