This is what is used. Dialog works perfectly fine but Hero animation doesn't work with that, so instead, this approach worked for me.
Navigator.of(context).push(
PageRouteBuilder(
opaque: true,
barrierDismissible: false,
pageBuilder: (BuildContext context, _, __) {
return Scaffold(
body: SafeArea(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Align(
alignment: Alignment.topRight,
child: IconButton(
onPressed: () =>
Navigator.of(context).pop(),
icon: const Icon(
Icons.cancel_sharp)),
),
Expanded(
child: InteractiveViewer(
scaleEnabled: true,
panEnabled: true,
child: Hero(
tag: user.photoUrl,
child: Center(
child: CachedNetworkImage(
imageUrl: user.photoUrl,
placeholder: (context, url) =>
const CupertinoActivityIndicator(),
),
),
),
),
),
],
),
),
);
},
),
);