-
-
Save yaizudamashii/403e91e3e2b9964b95c825a577dbbcf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AutoDisposeStreamProvider<RoomDetailViewModel> createUsersStreamProvider({ Room room }) { | |
return StreamProvider.autoDispose<RoomDetailViewModel>((ref) { | |
final database = ref.watch(databaseProvider); | |
final agora = ref.watch(agoraProvider); | |
final currentUserStream = ref.watch(userProvider); | |
if (database != null && agora != null && currentUserStream != null) { | |
return currentUserStream.when( | |
data: (User currentUser) { | |
return database.roomStream(agoraService: agora, room: room, currentUser: currentUser); | |
}, | |
loading: () => const Stream.empty(), | |
error: (error, stackTrace) => const Stream.empty() | |
); | |
} | |
return const Stream.empty(); | |
}); | |
} | |
// 略 | |
RoomDetailScreen({ @required this.room }) | |
: usersStreamProvider = createUsersStreamProvider(room: room); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment