'How to Widget test Share package using widget test

I have an issue with trying to test Share package. My code looks like this:

IconButton(
  key: Key('share-button'),
  icon: Icon(Platform.isAndroid ? Icons.share : CupertinoIcons.share),
  onPressed: () {
     if (activity.shareLink != null) {
      Share.share('${activity.shareLink}');
     } else {
      ScaffoldMessenger.of(context).showSnackBar(
       SnackBar(
        content: Text('Request Error'),
       ),
      );
     }
    },
   )

I provided [activity.shareLink] and my test looks like this:

await tester.tap(find.byKey(Key('share-button')));
await tester.pump(Duration(seconds: 1));
expect(find.byType(Share), findsOneWidget); 

And my exception is:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: _WidgetTypeFinder:<zero widgets with type "Share" (ignoring offstage widgets)>
   Which: means none were found but one was expected


Solution 1:[1]

this is how they test the package in their GitHub library, maybe you should test it this way:

expect(Share.share('message', subject: 'title'), completes);

Github Repository share_plus

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 th_lo