cake_wallet/lib/entities/ios_legacy_helper.dart

26 lines
920 B
Dart
Raw Normal View History

2020-09-21 16:56:41 +00:00
import 'dart:async';
2020-09-23 18:26:10 +00:00
import 'dart:typed_data';
2020-09-21 16:56:41 +00:00
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
const platform =
const MethodChannel('com.cakewallet.cakewallet/legacy_wallet_migration');
2020-09-23 18:26:10 +00:00
Future<String> decrypt(Uint8List bytes,
2022-10-12 17:09:57 +00:00
{required String key, required String salt}) async =>
(await platform
.invokeMethod<String>('decrypt', {'bytes': bytes, 'key': key, 'salt': salt}))!;
2020-09-21 16:56:41 +00:00
2022-10-12 17:09:57 +00:00
Future<dynamic> readUserDefaults(String key, {required String type}) async =>
2020-09-23 18:26:10 +00:00
await platform
.invokeMethod<dynamic>('read_user_defaults', {'key': key, 'type': type});
2022-10-12 17:09:57 +00:00
Future<String?> getString(String key) async =>
await readUserDefaults(key, type: 'string') as String?;
2020-09-23 18:26:10 +00:00
2022-10-12 17:09:57 +00:00
Future<bool?> getBool(String key) async =>
await readUserDefaults(key, type: 'bool') as bool?;
2020-09-23 18:26:10 +00:00
2022-10-12 17:09:57 +00:00
Future<int?> getInt(String key) async =>
await readUserDefaults(key, type: 'int') as int?;