Skip to content

Commit 35a9bb0

Browse files
gnpricechrisbobbe
authored andcommitted
store: Implement toString on PerAccountStore and friends
The `shortHash` identity tags can be helpful in debugging.
1 parent 6a66699 commit 35a9bb0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/model/store.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ abstract class GlobalStore extends ChangeNotifier {
134134

135135
// More mutators as needed:
136136
// Future<void> updateAccount...
137+
138+
@override
139+
String toString() => '${objectRuntimeType(this, 'GlobalStore')}#${shortHash(this)}';
137140
}
138141

139142
/// Store for the user's data for a given Zulip account.
@@ -398,6 +401,9 @@ class PerAccountStore extends ChangeNotifier with StreamStore {
398401
final nonDisplayFields = initialCustomProfileFields.where((e) => e.displayInProfileSummary != true);
399402
return displayFields.followedBy(nonDisplayFields).toList();
400403
}
404+
405+
@override
406+
String toString() => '${objectRuntimeType(this, 'PerAccountStore')}#${shortHash(this)}';
401407
}
402408

403409
const _apiSendMessage = sendMessage; // Bit ugly; for alternatives, see: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20PerAccountStore.20methods/near/1545809
@@ -462,6 +468,9 @@ class LiveGlobalStore extends GlobalStore {
462468
..where((a) => a.id.equals(accountId))
463469
).getSingle();
464470
}
471+
472+
@override
473+
String toString() => '${objectRuntimeType(this, 'LiveGlobalStore')}#${shortHash(this)}';
465474
}
466475

467476
/// A [PerAccountStore] plus an event-polling loop to stay up to date.
@@ -573,4 +582,7 @@ class UpdateMachine {
573582
if (token == null) return;
574583
await NotificationService.registerToken(store.connection, token: token);
575584
}
585+
586+
@override
587+
String toString() => '${objectRuntimeType(this, 'UpdateMachine')}#${shortHash(this)}';
576588
}

0 commit comments

Comments
 (0)