Skip to content

Commit ae5f9a6

Browse files
committed
fix(account): await ad dismissal before navigating
- Modify the onTap callback to asynchronously wait for the interstitial ad to be shown and dismissed - Add a check to ensure the widget is still mounted before navigating - Update the navigation to be performed after the ad is closed
1 parent 24f9e0e commit ae5f9a6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/account/view/manage_followed_items/topics/followed_topics_list_page.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,17 @@ class FollowedTopicsListPage extends StatelessWidget {
101101
);
102102
},
103103
),
104-
onTap: () {
105-
context.read<InterstitialAdManager>().onPotentialAdTrigger();
106-
context.pushNamed(
104+
onTap: () async {
105+
// Await for the ad to be shown and dismissed.
106+
await context
107+
.read<InterstitialAdManager>()
108+
.onPotentialAdTrigger();
109+
110+
// Check if the widget is still in the tree before navigating.
111+
if (!context.mounted) return;
112+
113+
// Proceed with navigation after the ad is closed.
114+
await context.pushNamed(
107115
Routes.entityDetailsName,
108116
pathParameters: {
109117
'type': ContentType.topic.name,

0 commit comments

Comments
 (0)