Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.6k stars 405 forks source link

deepLinkTransformer and deepLinkBuilder called twice in iOS cold start #2093

Open jv-soares opened 1 week ago

jv-soares commented 1 week ago

Hey guys it seems that deepLinkTransformer and deepLinkBuilder are being called twice whenever i launch the app on iOS by tapping on a deep link in any notes app. No problem on Android. Anyone knows why?

Version: 9.2.0

main.dart ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); await Environment.setup(); await Firebase.initializeApp(); await CrashReporter.runApp(() async { _setTransparentStatusBar(); _setPreferredOrientations(); await SharedPreferencesWrapper.instance.initialise(); GetItManager.setup(); await FirebaseRemoteConfigWrapper.fetch(); runApp(const ProviderScope(child: App())); }); } void _setPreferredOrientations() { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); } void _setTransparentStatusBar() { SystemChrome.setSystemUIOverlayStyle( const SystemUiOverlayStyle( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.dark, statusBarBrightness: Brightness.light, ), ); } ```
app.dart ```dart class App extends StatefulWidget { const App({super.key}); @override State createState() => _AppState(); } class _AppState extends State { final _appRouter = getIt(); @override Widget build(BuildContext context) { return MaterialApp.router( title: 'Aparkado', debugShowCheckedModeBanner: false, routerConfig: _appRouter.config( deepLinkTransformer: DeepLinkHandler.deepLinkTransformer, deepLinkBuilder: DeepLinkHandler.deepLinkBuilder, ), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, theme: buildThemeData(), ); } } ```
flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-DE) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.2) [✓] VS Code (version 1.95.3) [✓] Connected device (3 available) [✓] Network resources • No issues found!
mrverdant13 commented 1 week ago

Hey, @jv-soares 👋🏼

That is the expected behaviour for deep links in iOS

You can find more details about the different scenarios in the official Flutter docs page for deep links

jv-soares commented 3 days ago

Hi @mrverdant13 thx for the reply!

I've read about these scenarios but i think the connection between these details and the behavior with deepLinkBuilder and deepLinkTransformer is still not clear enough, since the docs mostly mention implementation details such as RouteInformationParser and RouterDelegate.setNewRoutePath. I'd say its important to point out this behavior in the auto_route docs.

Another problem i faced and that might be related is that PlatformDeepLink.initial also has different values on Android vs iOS. I was using it to check whether the deep link triggered an app cold start or not.

Do you know how i could detect a cold start from the deep link?