I have just developed an eCommerce app using flutter framework, I am trying to share specific URL for any product so the customer can open this product details screen in the app using the shared URL. I have used uni_links package to handle with this link, but I don't know what is the problem because the app doesn't open when I open the URL in the browser, here are the codes that I used.
1- AndroidManifest.xml
<application
android:name="io.flutter.app.FlutterApplication"
android:label="ecards"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="unilinks"
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>
2- uni_links code that is used to handle URL
import 'dart:async';
import 'package:uni_links/uni_links.dart';
StreamSubscription _sub;
Future<Null> initUniLinks() async {
_sub = getLinksStream().listen((String link) {
print(link);
}, onError: (err) {
print(err);
});
}
3- Main file in Flutter project
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initUniLinks();
await translator.init(
localeDefault: LocalizationDefaultType.device,
languagesList: <String>['ar', 'en'],
assetsDirectory: 'assets/langs/',
);
note: I am using Xiaomi mi 9t to test the app