@@ -22,6 +22,7 @@ import 'package:flutter_pecha/features/notifications/application/notification_sy
2222import 'package:flutter_pecha/features/notifications/data/services/notification_service.dart' ;
2323import 'package:flutter_pecha/features/home/data/datasource/home_local_datasource.dart' ;
2424import 'package:flutter_pecha/features/home/presentation/providers/use_case_providers.dart' ;
25+ import 'package:flutter_pecha/features/auth/presentation/providers/state_providers.dart' ;
2526import 'package:flutter_pecha/features/mala/data/datasources/mala_local_datasource.dart' ;
2627import 'package:flutter_pecha/features/mala/presentation/providers/mala_providers.dart' ;
2728import 'package:flutter_pecha/features/more/data/datasource/user_stats_local_datasource.dart' ;
@@ -202,6 +203,7 @@ class MyApp extends ConsumerStatefulWidget {
202203
203204class _MyAppState extends ConsumerState <MyApp > with WidgetsBindingObserver {
204205 bool _hasRegisteredDeepLinkRouters = false ;
206+ bool _hasDrainedInitialAppLink = false ;
205207
206208 @override
207209 void initState () {
@@ -238,6 +240,7 @@ class _MyAppState extends ConsumerState<MyApp> with WidgetsBindingObserver {
238240 Widget build (BuildContext context) {
239241 final locale = ref.watch (localeProvider);
240242 final themeMode = ref.watch (themeModeProvider);
243+ final authState = ref.watch (authProvider);
241244
242245 // Get the singleton router instance - same instance is reused across rebuilds
243246 // final router = AppRouter().router;
@@ -253,6 +256,14 @@ class _MyAppState extends ConsumerState<MyApp> with WidgetsBindingObserver {
253256 _hasRegisteredDeepLinkRouters = true ;
254257 }
255258
259+ if (! authState.isLoading && ! _hasDrainedInitialAppLink) {
260+ WidgetsBinding .instance.addPostFrameCallback ((_) {
261+ if (! mounted) return ;
262+ AppLinksDeepLinkService .instance.drainPendingLink ();
263+ _hasDrainedInitialAppLink = true ;
264+ });
265+ }
266+
256267 // Initialize services in background via providers
257268 ref.watch (audioHandlerProvider);
258269 ref.watch (notificationServiceProvider);
0 commit comments