fix bug download button in web.

This commit is contained in:
OkaykOrhmn 2025-01-09 12:18:12 +03:30
parent 3814bf14ff
commit 1d67da9598
2 changed files with 27 additions and 10 deletions

View File

@ -68,7 +68,6 @@ Future<void> _backgroundCallbackHomeWidget(Uri? uri) async {
void main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
if (!kIsWeb) {
HomeWidget.registerBackgroundCallback(_backgroundCallbackHomeWidget);

View File

@ -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<AiChatPage> {
),
),
),
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<AiChatPage> {
),
),
),
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),