easy_app_links 1.0.1 copy "easy_app_links: ^1.0.1" to clipboard
easy_app_links: ^1.0.1 copied to clipboard

A powerful diagnostic tool to verify and handle Android/iOS deep links with zero-config console reporting.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:easy_app_links/easy_app_links.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize Easy App Links
  await EasyAppLinks.init(
    domain: "yourdomain.com", // Your web domain
    sha256: "YOUR_SHA256_FINGERPRINT", // Your App's SHA-256
    onLink: (uri, params) {
      print("🔗 Path: ${uri.path}");
      print("📊 Query Params: $params");

      // Navigate to specific page based on path
      if (uri.path == '/product') {
        navigatorKey.currentState?.pushNamed('/product', arguments: params);
      } else if (uri.path == '/profile') {
        navigatorKey.currentState?.pushNamed('/profile', arguments: params);
      } else if (uri.path == '/home') {
        navigatorKey.currentState?.pushNamed('/home');
      }
    },
  );

  runApp(const MyApp());
}

// Global navigator key for deep link navigation
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      title: 'Easy App Links Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        useMaterial3: true,
      ),
      initialRoute: '/',
      routes: {
        '/': (context) => const HomePage(),
        '/product': (context) => ProductPage(arguments: ModalRoute.of(context)?.settings.arguments),
        '/profile': (context) => ProfilePage(arguments: ModalRoute.of(context)?.settings.arguments),
        '/home': (context) => const HomePage(),
      },
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Easy App Links Example'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Icon(
              Icons.link,
              size: 80,
              color: Colors.blue,
            ),
            const SizedBox(height: 20),
            const Text(
              'Easy App Links is initialized!',
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 10),
            const Text(
              'Try opening these deep links to test the functionality:',
              textAlign: TextAlign.center,
              style: TextStyle(fontSize: 16),
            ),
            const SizedBox(height: 20),
            _buildLinkCard(context, 'yourdomain.com/home', 'Home Page'),
            _buildLinkCard(context, 'yourdomain.com/product?id=123', 'Product Page'),
            _buildLinkCard(context, 'yourdomain.com/profile?name=John', 'Profile Page'),
            const SizedBox(height: 20),
            const Text(
              '📱 Make sure to replace "yourdomain.com" and "YOUR_SHA256_FINGERPRINT" with your actual values!',
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: 14,
                color: Colors.orange,
                fontWeight: FontWeight.w500,
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildLinkCard(BuildContext context, String link, String description) {
    return Card(
      margin: const EdgeInsets.symmetric(vertical: 8),
      child: Padding(
        padding: const EdgeInsets.all(12),
        child: Row(
          children: [
            const Icon(Icons.link, color: Colors.blue),
            const SizedBox(width: 12),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    description,
                    style: const TextStyle(
                      fontWeight: FontWeight.bold,
                      fontSize: 16,
                    ),
                  ),
                  Text(
                    link,
                    style: TextStyle(
                      fontSize: 14,
                      color: Colors.grey[600],
                    ),
                  ),
                ],
              ),
            ),
            IconButton(
              icon: const Icon(Icons.copy),
              onPressed: () {
                // Copy link to clipboard functionality would go here
                ScaffoldMessenger.of(context).showSnackBar(
                  const SnackBar(content: Text('Link copied!')),
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}

class ProductPage extends StatelessWidget {
  final dynamic arguments;
  
  const ProductPage({super.key, this.arguments});

  @override
  Widget build(BuildContext context) {
    final params = arguments as Map<String, String>? ?? {};
    final productId = params['id'] ?? 'Unknown';
    
    return Scaffold(
      appBar: AppBar(
        title: Text('Product $productId'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Icon(
              Icons.shopping_bag,
              size: 80,
              color: Colors.green,
            ),
            const SizedBox(height: 20),
            Text(
              'Product ID: $productId',
              style: const TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 10),
            const Text(
              'This page was opened via deep link!',
              style: TextStyle(fontSize: 16),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () => Navigator.of(context).pop(),
              child: const Text('Go Back'),
            ),
          ],
        ),
      ),
    );
  }
}

class ProfilePage extends StatelessWidget {
  final dynamic arguments;
  
  const ProfilePage({super.key, this.arguments});

  @override
  Widget build(BuildContext context) {
    final params = arguments as Map<String, String>? ?? {};
    final name = params['name'] ?? 'Guest';
    
    return Scaffold(
      appBar: AppBar(
        title: Text('Profile'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Icon(
              Icons.person,
              size: 80,
              color: Colors.purple,
            ),
            const SizedBox(height: 20),
            Text(
              'Welcome, $name!',
              style: const TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 10),
            const Text(
              'This profile was opened via deep link!',
              style: TextStyle(fontSize: 16),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () => Navigator.of(context).pop(),
              child: const Text('Go Back'),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
155
points
44
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A powerful diagnostic tool to verify and handle Android/iOS deep links with zero-config console reporting.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

app_links, flutter, http, package_info_plus

More

Packages that depend on easy_app_links