Skip to content

Commit 0115466

Browse files
committed
Update button_share.dart
1 parent 712d2d2 commit 0115466

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

lib/widgets/button_share.dart

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:apidash_design_system/apidash_design_system.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:flutter/foundation.dart';
43
import 'package:apidash/consts.dart';
54
import 'package:share_plus/share_plus.dart';
65

@@ -17,29 +16,22 @@ class ShareButton extends StatelessWidget {
1716
@override
1817
Widget build(BuildContext context) {
1918
var sm = ScaffoldMessenger.of(context);
20-
onPressed() async {
21-
try {
22-
final box = context.findRenderObject() as RenderBox?;
23-
await Share.share(
24-
toShare,
25-
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
26-
);
27-
} catch (e) {
28-
if (kDebugMode) {
29-
print(e);
30-
}
31-
sm.hideCurrentSnackBar();
32-
sm.showSnackBar(getSnackBar("Cannot share"));
33-
}
34-
}
3519

3620
return ADIconButton(
3721
icon: Icons.share,
3822
iconSize: kButtonIconSizeLarge,
3923
tooltip: kLabelShare,
4024
color: Theme.of(context).colorScheme.primary,
4125
visualDensity: VisualDensity.compact,
42-
onPressed: onPressed,
26+
onPressed: () async {
27+
sm.hideCurrentSnackBar();
28+
try {
29+
await Share.share(toShare);
30+
} catch (e) {
31+
debugPrint("$e");
32+
sm.showSnackBar(getSnackBar(kMsgShareError));
33+
}
34+
},
4335
);
4436
}
4537
}

0 commit comments

Comments
 (0)