getUser method

  1. @override
Future<EarthoUser?> getUser()
override

After user connected, this function returns user object

Implementation

@override
Future<EarthoUser?> getUser() async {
  try {
    if (earthoInstance == null) return null;
    final eToken = await promiseToFuture(earthoInstance?.getIdToken());
    if (eToken == null) return null;
    Map<String, dynamic> decodedToken = JwtDecoder.decode(eToken as String);
    return EarthoUser.fromJSON(decodedToken["user"]);
  } catch (e) {
    print(e);
    return null;
  }
}