Skip to content

Instantly share code, notes, and snippets.

@salihgueler
Created May 12, 2023 10:15
Show Gist options
  • Save salihgueler/2f293e04b56a12961df0588d44b75223 to your computer and use it in GitHub Desktop.
Save salihgueler/2f293e04b56a12961df0588d44b75223 to your computer and use it in GitHub Desktop.
@override
Widget build(BuildContext context) {
return SizedBox.square(
dimension: 100,
child:
BlocBuilder<PreviousGroceryDetailsCubit, PreviousGroceryDetailsState>(
bloc: previousGroceryDetailsCubit,
builder: (context, state) {
if (state is PreviousGroceryDetailsSuccess) {
return CachedNetworkImage(
imageUrl: state.fileUrl,
imageBuilder: (context, imageProvider) => DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
image: DecorationImage(
image: NetworkImage(
state.fileUrl,
),
fit: BoxFit.cover,
),
),
),
placeholder: (context, url) => const Center(child: CircularProgressIndicator()),
errorWidget: (context, url, error) => const Icon(Icons.error),
);
} else if (state is PreviousGroceryDetailsError) {
return Center(child: Text(state.errorMessage));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment