fix: uninitialized error in members setting page (#4834)

This commit is contained in:
Lucas.Xu 2024-03-07 09:28:31 +08:00 committed by GitHub
parent f5cb8b6d25
commit f484675008
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 5 deletions

View File

@ -113,8 +113,7 @@ class WorkspaceMenuItem extends StatelessWidget {
return BlocProvider( return BlocProvider(
create: (_) => create: (_) =>
WorkspaceMemberBloc(userProfile: userProfile, workspace: workspace) WorkspaceMemberBloc(userProfile: userProfile, workspace: workspace)
..add(const WorkspaceMemberEvent.initial()) ..add(const WorkspaceMemberEvent.initial()),
..add(const WorkspaceMemberEvent.getWorkspaceMembers()),
child: BlocBuilder<WorkspaceMemberBloc, WorkspaceMemberState>( child: BlocBuilder<WorkspaceMemberBloc, WorkspaceMemberState>(
builder: (context, state) { builder: (context, state) {
final members = state.members; final members = state.members;

View File

@ -38,6 +38,8 @@ class WorkspaceMemberBloc
workspaceId = ''; workspaceId = '';
}); });
} }
add(const WorkspaceMemberEvent.getWorkspaceMembers());
}, },
getWorkspaceMembers: () async { getWorkspaceMembers: () async {
final members = await _getWorkspaceMembers(); final members = await _getWorkspaceMembers();

View File

@ -27,9 +27,7 @@ class WorkspaceMembersPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider<WorkspaceMemberBloc>( return BlocProvider<WorkspaceMemberBloc>(
create: (context) => WorkspaceMemberBloc(userProfile: userProfile) create: (context) => WorkspaceMemberBloc(userProfile: userProfile)
..add( ..add(const WorkspaceMemberEvent.initial()),
const WorkspaceMemberEvent.getWorkspaceMembers(),
),
child: BlocBuilder<WorkspaceMemberBloc, WorkspaceMemberState>( child: BlocBuilder<WorkspaceMemberBloc, WorkspaceMemberState>(
builder: (context, state) { builder: (context, state) {
return SingleChildScrollView( return SingleChildScrollView(