Repository navigation
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectf: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.27Found to occur in 3.27Found to occur in 3.27found in release: 3.28Found to occur in 3.28Found to occur in 3.28frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Steps to reproduce
- Run the code sample
- Run this command to test deeplink.
adb shell 'am start -a android.intent.action.VIEW \
-c android.intent.category.BROWSABLE \
-d "https://example.com/test"' \
com.example.test- Note the printed value of
onGenerateRoutemethod - Stop the app
- Run
flutter logs - Run this command again
adb shell 'am start -a android.intent.action.VIEW \
-c android.intent.category.BROWSABLE \
-d "https://example.com/test"' \
com.example.test- Note the printed value by
onGenerateInitialRoutesmethod
Expected results
The two printed values should be the same
Actual results
The two values are different. onGenerateInitialRoutes keeps all the url https://example.com/test while onGenerateRoute keeps only the path /test.
Code sample
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
final route = MaterialPageRoute(builder: (context) => Text('Page'));
return MaterialApp(
title: 'Example',
onGenerateRoute: (settings) {
print(settings.name);
return route;
},
onGenerateInitialRoutes: (intitialRoute) {
print(intitialRoute);
return [route];
},
);
}
}AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="test"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="example.com" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>Flutter Version
Flutter version 3.28.0-0.1.pre on channel beta
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectf: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.27Found to occur in 3.27Found to occur in 3.27found in release: 3.28Found to occur in 3.28Found to occur in 3.28frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Activity
darshankawar commentedon Jan 20, 2025
@julien4215
Please check the behavior described for https://api.flutter.dev/flutter/material/MaterialApp/onGenerateRoute.html to see if it helps further in your case as why it could be different behavior.
julien4215 commentedon Jan 20, 2025
@darshankawar
It doesn't explain the different behavior. I think that
initialRouteshould only be the path without the scheme and the base url or else mention in the documentation that there is this different behavior when using a deeplink.darshankawar commentedon Jan 21, 2025
Thanks for the update. I do see the same behavior upon following the details as provided.
goderbauer commentedon Jan 21, 2025
@chunhtai I think this is expected behavior. Can you confirm?