urlynk_flutter 1.0.0 copy "urlynk_flutter: ^1.0.0" to clipboard
urlynk_flutter: ^1.0.0 copied to clipboard

A Flutter plugin that provides complete solution for deferred deep linking and URL shortening.

example/lib/main.dart

import 'dart:async';
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:urlynk_flutter/urlynk_flutter.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _urlynk = UrlynkFlutter();

  @override
  void initState() {
    super.initState();
    _init();
  }

  Future<void> _init() async {
    // Configure URLynk service. Must be called before using any other methods.
    await _urlynk.configure(appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY');
    log('URLynk configured successfully');

    // Listen for deep link data
    _urlynk.onLinkData.listen((data) {
      log('Received link data: $data');
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('URLynk Example')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: _createDeepLink,
                child: const Text('Create Deep Link'),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: _createShortLink,
                child: const Text('Create Short Link'),
              ),
              const SizedBox(height: 20),
              StreamBuilder<String>(
                stream: _urlynk.onLinkData,
                builder: (context, snapshot) {
                  if (snapshot.connectionState == ConnectionState.active) {
                    final linkData = snapshot.data;
                    return Text('Received Link Data: ${linkData ?? ''}');
                  }
                  return const Text('Waiting for link data...');
                },
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<void> _createDeepLink() async {
    final deepLink = await _urlynk.createDeepLink(
      jsonEncode({'referredBy': '12345', 'referralCode': 'WELCOME50'}),
    );
    if (deepLink != null) log('Deep link created: $deepLink');
  }

  Future<void> _createShortLink() async {
    final shortLink = await _urlynk.createShortLink(
      url: 'https://example.com/very-long-url',
    );
    if (shortLink != null) log('Short link created: $shortLink');
  }
}
6
likes
0
points
26
downloads

Publisher

verified publishervalueoutput.com

Weekly Downloads

A Flutter plugin that provides complete solution for deferred deep linking and URL shortening.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on urlynk_flutter

Packages that implement urlynk_flutter