File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 1+ import 'dart:async' ;
12import 'dart:io' ;
23
34import 'package:flutter/material.dart' ;
@@ -14,14 +15,22 @@ class ShareHelpers {
1415 List <XFile > files,
1516 String text,
1617 ) async {
17- await Share .shareXFiles (
18- files,
19- text: text,
20- );
18+ try {
19+ await Share .shareXFiles (
20+ files,
21+ text: text,
22+ ).timeout (const Duration (seconds: 5 ));
23+ } on TimeoutException {
24+ return ;
25+ }
2126 }
2227
2328 Future <void > shareOnlyPost (List <XFile > files) async {
24- await Share .shareXFiles (files);
29+ try {
30+ await Share .shareXFiles (files).timeout (const Duration (seconds: 5 ));
31+ } on TimeoutException {
32+ return ;
33+ }
2534 }
2635
2736 Future <void > captureAndShare ({
@@ -41,11 +50,14 @@ class ShareHelpers {
4150 final filePath = '${tempDir .path }/shared_image.png' ;
4251 final file = File (filePath);
4352 await file.writeAsBytes (screenshotBytes);
53+ // シェア処理を実行(タイムアウト付き)
4454 if (hasText) {
4555 await sharePosts ([XFile (file.path)], shareText! );
4656 } else {
4757 await shareOnlyPost ([XFile (file.path)]);
4858 }
59+ } on Exception {
60+ return ;
4961 } finally {
5062 loading.value = false ;
5163 }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class AppShareWidget extends StatelessWidget {
3737 child: CachedNetworkImage (
3838 imageUrl: supabase.storage
3939 .from ('food' )
40- .getPublicUrl (posts.foodImage ),
40+ .getPublicUrl (posts.firstFoodImage ),
4141 fit: BoxFit .cover,
4242 ),
4343 ),
You can’t perform that action at this time.
0 commit comments