Skip to main content

deep_links_kit 0.1.0 copy "deep_links_kit: ^0.1.0" to clipboard
deep_links_kit: ^0.1.0 copied to clipboard

One config for Android App Links and iOS Universal Links: a CLI that sets up the native projects and server files, plus router-agnostic link handling.

example/lib/main.dart

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

final navigatorKey = GlobalKey<NavigatorState>();

final deepLinks = DeepLinksKit(
  navigator: DeepLinkNavigator.named(navigatorKey),
  hosts: {'app.example.com'},
  schemes: {'myapp'},
  routes: [
    DeepLinkRoute('/p/:id', to: (match) => '/profile?id=${match['id']}'),
  ],
  fallback: (_) => '/',
);

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  deepLinks.init();
  runApp(const ExampleApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      onGenerateRoute: (settings) {
        final uri = Uri.parse(settings.name ?? '/');
        final page = uri.path == '/profile'
            ? ProfilePage(id: uri.queryParameters['id'] ?? '')
            : const HomePage();
        return MaterialPageRoute(builder: (_) => page, settings: settings);
      },
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Center(child: Text('Open myapp://p/42 to see a profile')),
    );
  }
}

class ProfilePage extends StatelessWidget {
  const ProfilePage({super.key, required this.id});

  final String id;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(child: Text('Profile $id')),
    );
  }
}
5
likes
160
points
145
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

One config for Android App Links and iOS Universal Links: a CLI that sets up the native projects and server files, plus router-agnostic link handling.

Repository (GitHub)
View/report issues

Topics

#deep-linking #app-links #universal-links #navigation #cli

License

MIT (license)

Dependencies

app_links, args, flutter, yaml

More

Packages that depend on deep_links_kit