@@ -202,6 +202,21 @@ class MyHomePageState extends State<MyHomePage> {
202202 },
203203 ),
204204 const SizedBox (height: 16 ),
205+ Builder (
206+ builder: (BuildContext context) {
207+ return ElevatedButton (
208+ style: ElevatedButton .styleFrom (
209+ foregroundColor: Theme .of (context).colorScheme.onPrimary,
210+ backgroundColor: Theme .of (context).colorScheme.primary,
211+ ),
212+ onPressed: () {
213+ _onShareXFileFromAssets (context, attach: true );
214+ },
215+ child: const Text ('Attach XFile from Assets' ),
216+ );
217+ },
218+ ),
219+ const SizedBox (height: 16 ),
205220 Builder (
206221 builder: (BuildContext context) {
207222 return ElevatedButton (
@@ -293,7 +308,10 @@ class MyHomePageState extends State<MyHomePage> {
293308 scaffoldMessenger.showSnackBar (getResultSnackBar (shareResult));
294309 }
295310
296- void _onShareXFileFromAssets (BuildContext context) async {
311+ void _onShareXFileFromAssets (
312+ BuildContext context, {
313+ bool attach = false ,
314+ }) async {
297315 final box = context.findRenderObject () as RenderBox ? ;
298316 final scaffoldMessenger = ScaffoldMessenger .of (context);
299317 try {
@@ -311,6 +329,7 @@ class MyHomePageState extends State<MyHomePage> {
311329 sharePositionOrigin: box! .localToGlobal (Offset .zero) & box.size,
312330 downloadFallbackEnabled: true ,
313331 excludedCupertinoActivities: excludedCupertinoActivityType,
332+ attach: attach,
314333 ),
315334 );
316335 scaffoldMessenger.showSnackBar (getResultSnackBar (shareResult));
0 commit comments