From 1d67da9598492ada932491d27036b90ce8f8d2ec Mon Sep 17 00:00:00 2001 From: OkaykOrhmn Date: Thu, 9 Jan 2025 12:18:12 +0330 Subject: [PATCH] fix bug download button in web. --- lib/main.dart | 1 - lib/views/ai/ai_chat_page.dart | 36 +++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index c09485e..563169d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -68,7 +68,6 @@ Future _backgroundCallbackHomeWidget(Uri? uri) async { void main() async { WidgetsFlutterBinding.ensureInitialized(); - try { if (!kIsWeb) { HomeWidget.registerBackgroundCallback(_backgroundCallbackHomeWidget); diff --git a/lib/views/ai/ai_chat_page.dart b/lib/views/ai/ai_chat_page.dart index 9c83094..5171316 100644 --- a/lib/views/ai/ai_chat_page.dart +++ b/lib/views/ai/ai_chat_page.dart @@ -1,6 +1,7 @@ -// ignore_for_file: library_private_types_in_public_api, deprecated_member_use, depend_on_referenced_packages +// ignore_for_file: library_private_types_in_public_api, deprecated_member_use, depend_on_referenced_packages, unnecessary_import -import 'dart:io'; +import 'dart:io' show Platform; +import 'package:flutter/foundation.dart' show kIsWeb; import 'package:didvan/config/design_config.dart'; import 'package:didvan/config/theme_data.dart'; @@ -552,19 +553,14 @@ class _AiChatPageState extends State { ), ), ), - if (message.file != null && !Platform.isIOS) + if (message.file != null && kIsWeb) Padding( padding: const EdgeInsets.all(8.0), child: InkWell( onTap: () async { final url = '${RequestHelper.baseUrl + message.file.toString()}?accessToken=${RequestService.token}'; - kIsWeb - ? MediaService - .downloadFileFromWeb(url) - : await MediaService.downloadFile( - url, - name: message.fileName); + MediaService.downloadFileFromWeb(url); }, child: Icon( DidvanIcons.download_solid, @@ -575,6 +571,28 @@ class _AiChatPageState extends State { ), ), ), + if (message.file != null && !kIsWeb) + !Platform.isIOS + ? Padding( + padding: const EdgeInsets.all(8.0), + child: InkWell( + onTap: () async { + final url = + '${RequestHelper.baseUrl + message.file.toString()}?accessToken=${RequestService.token}'; + await MediaService.downloadFile( + url, + name: message.fileName); + }, + child: Icon( + DidvanIcons.download_solid, + size: 18, + color: Theme.of(context) + .colorScheme + .focusedBorder, + ), + ), + ) + : const SizedBox.shrink(), if (message.error != null && message.error!) Padding( padding: const EdgeInsets.all(8.0),