mediaSablon method
Implementation
Widget mediaSablon(
BuildContext context,
Rx<Post> postInfo,
String mediaUrl, {
required int indexlength,
BoxFit? fit = BoxFit.cover,
double? width = 100,
double? height = 100,
bool? isvideo = false,
bool islastmedia = false,
}) {
if (isvideo == true) {
log(mediaUrl);
if (Platform.isWindows) {
postInfo.value.mediaController =
MediaKitVideoControllerWrapper(mediaUrl);
} else {
final mobile = MobileVideoControllerWrapper(mediaUrl);
postInfo.value.mediaController = mobile;
mobile.initialize(mute: true); // sadece mobile initialize gerekiyor
}
var videoIsMute = true.obs;
return Stack(
children: [
FittedBox(
fit: BoxFit.cover,
child: InkWell(
onTap: () {
if (Platform.isWindows) {
if (videoIsMute.value) {
postInfo.value.mediaController!.setVolume(100.0);
videoIsMute.value = false;
} else {
postInfo.value.mediaController!.setVolume(0.0);
videoIsMute.value = true;
}
return;
}
if (Platform.isAndroid || Platform.isIOS) {
if (videoIsMute.value) {
postInfo.value.mediaController!.setVolume(100.0);
videoIsMute.value = false;
} else {
postInfo.value.mediaController!.setVolume(0.0);
videoIsMute.value = true;
}
}
},
child: SizedBox(
height: 500,
width: MediaQuery.of(context).size.width,
child: postInfo.value.mediaController!.getVideoWidget(),
),
),
),
],
);
}
if (islastmedia && indexlength > 4) {
return Container(
width: width,
height: height,
decoration: BoxDecoration(
image: DecorationImage(
colorFilter: ColorFilter.mode(
Colors.black..withValues(alpha: 0.4),
BlendMode.dstATop,
),
image: CachedNetworkImageProvider(
mediaUrl,
errorListener: (p0) => const Icon(Icons.error),
),
fit: fit,
),
),
child: Center(
child: Text(
"+${indexlength - 4}",
style: const TextStyle(fontSize: 50),
)),
);
} else {
return PinchZoom(
child: CachedNetworkImage(
imageUrl: mediaUrl,
fit: fit,
width: width, // Genişlik Kafayı yediği için yorum satırına aldık
height: height,
placeholder: (context, url) => const CupertinoActivityIndicator(),
errorWidget: (context, url, error) => const Icon(Icons.error),
),
);
}
}