vela_links 0.1.1
vela_links: ^0.1.1 copied to clipboard
Deep links, app links, deferred deep links, short links, share links, QR codes and link tracking for Flutter. A Firebase Dynamic Links alternative.
example/lib/main.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:vela_links/vela_links.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Replace with the SDK key from your Vela Links dashboard.
await VelaLinks.init(
apiKey: 'vl_your_sdk_key', baseUrl: 'https://api.links.velaapps.in');
runApp(const ExampleApp());
}
class ExampleApp extends StatefulWidget {
const ExampleApp({super.key});
@override
State<ExampleApp> createState() => _ExampleAppState();
}
class _ExampleAppState extends State<ExampleApp> {
VelaLink? _last;
StreamSubscription<VelaLink>? _subscription;
@override
void initState() {
super.initState();
_last = VelaLinks.instance.consumePendingLink();
_subscription = VelaLinks.instance.onLink
.listen((link) => setState(() => _last = link));
}
@override
void dispose() {
_subscription?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Vela Links example')),
body: Center(
child: Text(_last == null
? 'Open a link to see it here'
: 'Opened ${_last!.route} ${_last!.params}')),
),
);
}
}