getImage method
Widget
getImage({
- required BuildContext context,
- required String imagePath,
- required double height,
- required double width,
- required BoxFit fit,
Returns a widget to display the state's image with interactive zoom functionality.
context: The build context for rendering the dialog.imagePath: The path or URL of the image to display.height: The height of the image widget.width: The width of the image widget.fit: The box-fit behavior for the image.- Returns: A
GestureDetectorthat displays the image and supports zoom functionality.
Implementation
Widget getImage({
required BuildContext context,
required String imagePath,
required double height,
required double width,
required BoxFit fit,
}) {
return GestureDetector(
onTap: () {
showDialog(
context: context,
builder: (context) => Dialog(
child: InteractiveViewer(
maxScale: 4.0,
child: imagePath.startsWith('http')
? Image.network(
imagePath,
fit: BoxFit.contain,
)
: Image.asset(
imagePath,
fit: BoxFit.contain,
),
),
),
);
},
child: imagePath.startsWith('http')
? Image.network(
imagePath,
height: height,
width: width,
fit: fit,
)
: Image.asset(
imagePath,
height: height,
width: width,
fit: fit,
),
);
}