limelink_flutter 1.0.0
limelink_flutter: ^1.0.0 copied to clipboard
Flutter plugin for the LimeLink iOS and Android SDKs.
example/lib/main.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:limelink_flutter/limelink_flutter.dart';
const testProjectId = '550e8400-e29b-41d4-a716-446655440000';
void main() => runApp(const LimeLinkExampleApp());
class LimeLinkExampleApp extends StatelessWidget {
const LimeLinkExampleApp({super.key});
@override
Widget build(BuildContext context) => MaterialApp(
title: 'LimeLink SDK Example',
theme: ThemeData(colorSchemeSeed: Colors.lime, useMaterial3: true),
home: const LimeLinkExamplePage(),
);
}
class LimeLinkExamplePage extends StatefulWidget {
const LimeLinkExamplePage({super.key});
@override
State<LimeLinkExamplePage> createState() => _LimeLinkExamplePageState();
}
class _LimeLinkExamplePageState extends State<LimeLinkExamplePage> {
StreamSubscription<LimeLinkEvent>? _subscription;
String _status = 'Not initialized';
String _event = 'No event received';
@override
void initState() {
super.initState();
_subscription = LimeLink.events.listen(
(event) => setState(() => _event = event.runtimeType.toString()),
onError: (Object error) => setState(() => _event = 'Error: $error'),
);
_initialize();
}
Future<void> _initialize() async {
try {
await LimeLink.initialize(
const LimeLinkConfig(projectId: testProjectId, loggingEnabled: true),
);
final initialized = await LimeLink.isInitialized();
if (mounted) setState(() => _status = 'Initialized: $initialized');
} catch (error) {
if (mounted) setState(() => _status = 'Initialization failed: $error');
}
}
Future<void> _checkDeferred() async {
try {
final outcome = await LimeLink.handleDeferredDeepLink();
if (mounted) setState(() => _event = outcome.runtimeType.toString());
} catch (error) {
if (mounted) setState(() => _event = 'Deferred failed: $error');
}
}
@override
void dispose() {
_subscription?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('LimeLink SDK 1.0.1')),
body: Padding(
padding: const EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(_status, key: const Key('initialization-status')),
const SizedBox(height: 16),
Text(_event, key: const Key('event-status')),
const SizedBox(height: 24),
FilledButton(
onPressed: _initialize,
child: const Text('Initialize again'),
),
OutlinedButton(
onPressed: _checkDeferred,
child: const Text('Check deferred deep link'),
),
],
),
),
);
}