getUserContext static method

Future<SelfDescribing?> getUserContext()

Implementation

static Future<SelfDescribing?> getUserContext() async {
  final userJson = await cacheInstance.getValue(KeyConfig.gkVerifiedUserKey);
  var user = userJson != null ? jsonDecode(userJson) : null;
  var phone =
      user != null ? user!['phone']?.replaceAll(RegExp(r'^\+91'), '') : null;
  final numericPhoneNumber = int.tryParse(phone ?? '');

  if (numericPhoneNumber != null ||
      (user != null && user?['email'] != null)) {
    return _createContext(
      'user/jsonschema/1-0-0',
      {
        'phone': numericPhoneNumber?.toString() ?? '',
        'email': user?['email'] ?? '',
      },
    );
  }
  return null;
}