From 703134f28270614951f310e219143118bca92643 Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Sat, 22 Jun 2024 21:27:29 +0000 Subject: [PATCH] fix: hide "Play video" button for unsupported platforms (#235) Changed to hide the "Play video" button in `PostFormAttaches` if `video_player` is not supported for the platform. --- lib/view/widget/post_form_attaches.dart | 36 ++++++++++++++----------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/view/widget/post_form_attaches.dart b/lib/view/widget/post_form_attaches.dart index 72baffc7..2e697ea7 100644 --- a/lib/view/widget/post_form_attaches.dart +++ b/lib/view/widget/post_form_attaches.dart @@ -1,6 +1,6 @@ -import 'dart:typed_data'; import 'dart:ui'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -208,23 +208,27 @@ class PostFormAttaches extends ConsumerWidget { ), ), if (files[index].type?.startsWith('video/') ?? false) - ListTile( - leading: const Icon(Icons.play_arrow), - title: Text(t.aria.playVideo), - onTap: () => showDialog( - context: context, - builder: (context) => VideoDialog( - url: switch (files[index]) { - DrivePostFile(:final file) => file.url, - _ => null, - }, - file: switch (files[index]) { - LocalPostFile(:final file) => file, - _ => null, - }, + if (defaultTargetPlatform + case TargetPlatform.android || + TargetPlatform.iOS || + TargetPlatform.macOS) + ListTile( + leading: const Icon(Icons.play_arrow), + title: Text(t.aria.playVideo), + onTap: () => showDialog( + context: context, + builder: (context) => VideoDialog( + url: switch (files[index]) { + DrivePostFile(:final file) => file.url, + _ => null, + }, + file: switch (files[index]) { + LocalPostFile(:final file) => file, + _ => null, + }, + ), ), ), - ), if (files[index].type?.startsWith('audio/') ?? false) if (files[index] case DrivePostFile(:final file)) ListTile(