Skip to content

Instantly share code, notes, and snippets.

@kharitonovAL
Last active September 24, 2022 15:44
Show Gist options
  • Save kharitonovAL/154fba650a0eb3057f2471dfdf7ca52f to your computer and use it in GitHub Desktop.
Save kharitonovAL/154fba650a0eb3057f2471dfdf7ca52f to your computer and use it in GitHub Desktop.
BlocBuilder<HouseMessagesCubit, HouseMessagesState>(
builder: (context, state) {
if (state is HouseMessagesLoading) {
return const Center(
child: CircularProgressIndicator(),
);
} else if (state is HouseMessagesLoaded) {
if (state.list.isEmpty) {
return const Center(
child: Text(
AppString.houseNoMessages,
),
);
} else {
return Scrollbar(
controller: _messagesScrollController,
child: ListView.builder(
controller: _messagesScrollController,
itemCount: state.list.length,
shrinkWrap: true,
itemBuilder: (context, index) =>
HouseMessageListItem(
message: state.list[index],
),
),
);
}
} else if (state is HouseMessagesLoadFailed) {
return Center(
child: Text(
state.error.toString(),
),
);
}
return const Center(
child: CircularProgressIndicator(),
);
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment