Search code examples
androidflutterdeep-linking

while create deeplink of flutter showing this error


i already added this code in flutter app -> android -> src -> main -> androidmanifest.xml in this file but still now working

<!-- Intent filter for handling deep links -->
<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <!-- Accepts URIs that begin with "https://www.example.com/gizmos" -->
    <data
        android:scheme="https"
        android:host="www.example.com"
        android:pathPrefix="/gizmos" />
</intent-filter>

after adding this still not working


Solution

  • You have to add the "uni_links" package to the project first:

    import 'package:uni_links/uni_links.dart';
    void main() {  
        runApp(MyApp());
    }
    
    class MyApp extends StatefulWidget {  
        @override  
        MyAppState createState() => MyAppState();
    }
    
    class _MyAppState extends State<MyApp> {  
        @override  
        void initState() {    
            super.initState();    
            initUniLinks();  
        } 
    
        void initUniLinks() async {    
            String initialLink = await getInitialLink();    
            // Handle the initial link, e.g., by navigating to a specific screen  
        }  
    
        @override  Widget build(BuildContext context) {    
        // Your app's build method  
        }
    }