linkhive_flutter 1.4.0 copy "linkhive_flutter: ^1.4.0" to clipboard
linkhive_flutter: ^1.4.0 copied to clipboard

A Flutter plugin to connect with LinkHive for dynamic links.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:linkhive_flutter/linkhive_flutter.dart';

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

  await LinkHiveClient.instance.connect(
    baseUrl: 'https://api.linkhive.tech',
    projectId: '902900b2-1837-438c-befa-e6b1b24e39cf',
    clientId: 'client_6654508e-2694-429d-8a7e-9aa639ccf5b4',
  );

  print(LinkHiveClient.instance.isConnected);
  var deferred = await LinkHiveClient.instance.dynamicLinks.getDeferredLink();
  print(deferred);
  var initial = await LinkHiveClient.instance.dynamicLinks.getInitialLink();
  print('initial  $initial');
  LinkHiveClient.instance.dynamicLinks.onLinkReceived.listen((e) {
    print('link clicked  $e');
  });
  runApp(const MyApp());
}

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

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('LinkHive Plugin example app')),
        body: IconButton(
          icon: Text("https://berlin.linkhive.tech/fmjLsbBK"),
          onPressed: () {},
        ),
      ),
    );
  }
}