yourWidget method
Implementation
@override
Widget yourWidget(BuildContext context, ChatDashboardModel? value) {
var accessState = AccessBloc.getState(context);
if (accessState is AccessDetermined) {
var appId = app.documentID;
if (accessState.getMember() != null) {
var memberId = accessState.getMember()!.documentID;
var eliudQuery = EliudQuery()
.withCondition(EliudQueryCondition('appId', isEqualTo: appId))
.withCondition(
EliudQueryCondition('members', arrayContains: memberId));
var height = MediaQuery.of(context).size.height -
kToolbarHeight -
kBottomNavigationBarHeight;
var chatBloc = ChatBloc(
appId: appId,
thisMemberId: memberId,
blockedMembers:
accessState is LoggedIn ? accessState.blockedMembers : []);
var allChatsBloc = AllChatsBloc(
loggedIn: accessState is LoggedIn ? accessState : null,
chatBloc: chatBloc,
appId: appId,
thisMemberId: memberId,
orderBy: 'timestamp',
descending: true,
eliudQuery: eliudQuery,
roomRepository: roomRepository(appId: appId)!)
..add(LoadAllChats());
return SizedBox(
height: height,
width: double.infinity,
child: MultiBlocProvider(
providers: [
BlocProvider<AllChatsBloc>(create: (context) => allChatsBloc),
BlocProvider<ChatBloc>(create: (context) => chatBloc)
],
child: AllChatsWidget(
app: app,
blockedMembers: accessState is LoggedIn
? accessState.blockedMembers
: [],
memberId: memberId,
membersType: value!.membersType)));
} else {
return const Text('Member not available');
}
} else {
return const Text('App not loaded');
}
}