smartlinks_analytics 2.0.2 copy "smartlinks_analytics: ^2.0.2" to clipboard
smartlinks_analytics: ^2.0.2 copied to clipboard

Dart analytics and deep linking API for the SmartLinks Flutter SDK.

example/lib/main.dart

// ignore_for_file: deprecated_member_use

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

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

  final analytics = SmartLinksAnalytics();
  await analytics.initialize(apiKey: 'api-key');
  analytics.getLink((DeepLinkRoute route) {});

  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SmartLinks Analytics Example',
      home: const HomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('SmartLinks Analytics')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () =>
                  SmartLinksAnalytics().sendEvent('example_open', null),
              child: const Text('Send Event'),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: () async {
                final link = await SmartLinksAnalytics().generateLink(
                  route: '/home',
                );
                if (link != null && context.mounted) {
                  ScaffoldMessenger.of(
                    context,
                  ).showSnackBar(SnackBar(content: Text('Generated: $link')));
                }
              },
              child: const Text('Generate Link'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
150
points
186
downloads

Documentation

Documentation
API reference

Publisher

verified publishersmartlinks.live

Weekly Downloads

Dart analytics and deep linking API for the SmartLinks Flutter SDK.

Homepage
Repository (GitLab)
View/report issues

License

MIT (license)

Dependencies

flutter, smartlinks_core

More

Packages that depend on smartlinks_analytics