-
-
Save yaizudamashii/c911eb7b4b3e1efb9864d604c13bf773 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
/* | |
import割愛 | |
*/ | |
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(); | |
}); | |
} | |
class RoomDetailScreen extends ConsumerWidget { | |
final Room room; | |
final AutoDisposeStreamProvider<RoomDetailViewModel> usersStreamProvider; | |
RoomDetailScreen({ @required this.room }) | |
: usersStreamProvider = createUsersStreamProvider(room: room); | |
@override | |
Widget build(BuildContext context, ScopedReader watch) { | |
final currentUserStream = watch(userProvider); | |
final usersStream = watch(usersStreamProvider); | |
double screenWidth = MediaQuery.of(context).size.width; | |
int numTilesHorizontal = (screenWidth / 120).floor(); | |
return Scaffold( | |
/* | |
中略 | |
*/ | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment