heroiclabs / nakama-dart

Pure Dart Client for Nakama Server
https://heroiclabs.com/docs/nakama/client-libraries/dart
166 stars 51 forks source link

user.displayName does not parse int the client. #115

Open imaNNeo opened 1 week ago

imaNNeo commented 1 week ago

Hi, I'm using the client in my flutter game, I noticed that the display name is not parsed in the client.

For example, when I run this code, the location gets updated and I can read the new location. But the new display name is updated (I checked the console), but it cannot retrieve it from the back-end.

void updateUserDisplayName() async {
  await client.updateAccount(
    session: _currentSession,
    displayName: 'My Display Name',
    location: 'My Location',
  );
  await Future.delayed(const Duration(seconds: 1));
  final account = await client.getAccount(_currentSession);

  // prints: new displayName: null
  print('new displayName: ${account.user.displayName}');

  // prints: new location: My Location
  print('new location: ${account.user.location}');
}

As you can see, both have been updated in the console. But, the client cannot retrieve the display name. It's always null

image

Nakama client (dart) version: 1.1.0 Nakama back-end (server) version: 3.22.0+4a4c53d7

I'm running it on web, and this is my flutter doctor result:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Community Edition (version 2023.2)
[✓] VS Code (version 1.93.1)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

Does anyone know anything about it?

ilmalte commented 1 week ago

Hey @imaNNeo,

Many improvements and bug fixes have been pushed to main since Dart version 1.1.0, and they will be released soon. You might want to update your pubspec.yaml file to point directly to main for now:

dependencies:
  nakama:
    git:
      url: 'https://github.com/heroiclabs/nakama-dart.git'
      path: nakama

I've tested your code in a clean environment using server version 3.22.0. Everything is working smoothly with the version in main, but it's failing with the latest version available on pub.dev (1.1.0).

Please try it out on your end and let me know if you run into any issues. Looking forward to your feedback!

P.S. Your game development tutorial using Nakama looks really interesting, keep going!

imaNNeo commented 1 week ago

Hey,

Thanks for your quick response. I just tested it with the main branch and yes, the issue is gone!

Just to mention that the bug only happened on the web btw, when I checked it in Android, it was working correctly.

But now, with the latest changes, it works well on both the Web and Android platforms. There were some breaking changes, I solved them but I would like to ask 2 questions here. (the commit is here)

1 - Can you explain why rank and score in a leaderboard record are strings now? Because they were just integers before that. 2 - In which situation the records property is null in the LeaderboardRecordList?

Cheers!