Created
May 12, 2023 10:15
-
-
Save salihgueler/2f293e04b56a12961df0588d44b75223 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@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