shyun_link 2.3.2
shyun_link: ^2.3.2 copied to clipboard
Complete deeplink and short URL management with native platform integration. Ultra-simple ShyunLinkManager API, Android/iOS native setup included, Clean Architecture, and enterprise-grade error handling.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:shyun_link/shyun_link.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// 🎉 ShyunLinkManager로 5줄 초기화!
await ShyunLinkManager.initialize(
appScheme: 'myapp',
webBaseUrl: 'https://myapp.com',
apiServerUrl: 'https://api.myapp.com',
shortLinkDomain: 'myapp.ly',
onDeepLink: (context) {
print('🔗 딥링크 받음: ${context.pageType}, ID: ${context.pageId}');
},
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'ShyunLink Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const MyHomePage(title: 'ShyunLink v2.3.0 Example'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String _lastResult = 'No action yet';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
const Icon(Icons.link, size: 48, color: Colors.blue),
const SizedBox(height: 16),
const Text(
'ShyunLink v2.3.0 - Native Plugin Test',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const Text(
'Native Android/iOS Plugin Integration',
style: TextStyle(color: Colors.grey),
),
const SizedBox(height: 16),
Text(
'Last Result: $_lastResult',
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 14),
),
],
),
),
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () => _createShortLink(),
child: const Text('Create Short Link'),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => _shareStore(),
child: const Text('Share Store'),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => _testDeepLink(),
child: const Text('Test Deep Link'),
),
],
),
),
),
);
}
Future<void> _createShortLink() async {
try {
final link = await ShyunLinkManager.createShortLink(
type: 'store',
id: 12345,
metadata: {'source': 'example_test'},
);
setState(() {
_lastResult = link != null ? 'Short link created: $link' : 'Failed to create link';
});
} catch (e) {
setState(() {
_lastResult = 'Error: $e';
});
}
}
Future<void> _shareStore() async {
try {
final success = await ShyunLinkManager.shareStore(
12345,
customText: '🏪 Check out this amazing store!',
);
setState(() {
_lastResult = success ? 'Store shared successfully' : 'Failed to share store';
});
} catch (e) {
setState(() {
_lastResult = 'Error: $e';
});
}
}
Future<void> _testDeepLink() async {
try {
await ShyunLinkManager.processDeepLink('myapp://store/12345');
setState(() {
_lastResult = 'Deep link processed successfully';
});
} catch (e) {
setState(() {
_lastResult = 'Error: $e';
});
}
}
}