shyun_link 3.0.1 copy "shyun_link: ^3.0.1" to clipboard
shyun_link: ^3.0.1 copied to clipboard

Streamlined deeplink and short URL management with Clean Architecture. Focused on core functionality - ShyunLinkManager.createShortLink() and deeplink handling with multiple URL format support.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:shyun_link/shyun_link.dart';
import 'platform_config_example.dart';

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

  // 🎉 ShyunLinkManager로 HTTPS 우선 초기화!
  await ShyunLinkManager.initialize(
    // === HTTPS 기본 방식 ===
    webBaseUrl: 'https://cocl.nearound.co',
    
    // === 커스텀 스킴 호확성 ===
    fallbackScheme: 'nearound',
    enableHttpsFirst: true,
    enableCustomSchemeCompat: true,
    
    // === 기존 설정 ===
    apiServerUrl: 'https://api.nearound.co',
    shortLinkDomain: 'cocl.nearound.co',
    onDeepLink: (context) {
      debugPrint('🔥 딥링크 받음 (출처: ${context.source}): $context');
    },
  );

  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 HTTPS Deep Links 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 v3.1.0 - HTTPS First',
                        style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                      ),
                      const SizedBox(height: 8),
                      const Text(
                        'HTTPS 딥링크 기본, 커스텀 스킴 호확성 지원',
                        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: () => _generateHttpsDeepLink(),
                child: const Text('Generate HTTPS Deep Link'),
              ),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () => _generateLegacyDeepLink(),
                child: const Text('Generate Legacy Deep Link'),
              ),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () => _generateAllFormats(),
                child: const Text('Generate All Formats'),
              ),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () => _createShortLink(),
                child: const Text('Create Short Link'),
              ),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () => _testHttpsDeepLink(),
                child: const Text('Test HTTPS Deep Link'),
              ),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () => _testCustomSchemeDeepLink(),
                child: const Text('Test Custom Scheme Deep Link'),
              ),
              const SizedBox(height: 32),
              ElevatedButton(
                onPressed: () => Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => const PlatformConfigExamplePage(),
                  ),
                ),
                style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.orange,
                  foregroundColor: Colors.white,
                ),
                child: const Text('Platform Configuration Helper'),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<void> _generateHttpsDeepLink() async {
    try {
      final httpsUrl = ShyunLinkManager.generateDeepLink(
        'curationDetail',
        {'type': 'mainBannerCuration', 'id': 120},
      );
      
      setState(() {
        _lastResult = 'HTTPS Deep Link:\n$httpsUrl';
      });
    } catch (e) {
      setState(() {
        _lastResult = 'Error: $e';
      });
    }
  }

  Future<void> _generateLegacyDeepLink() async {
    try {
      final customUrl = ShyunLinkManager.generateLegacyDeepLink(
        'curationDetail',
        {'type': 'mainBannerCuration', 'id': 120},
      );
      
      setState(() {
        _lastResult = 'Custom Scheme Deep Link:\n$customUrl';
      });
    } catch (e) {
      setState(() {
        _lastResult = 'Error: $e';
      });
    }
  }

  Future<void> _generateAllFormats() async {
    try {
      final urls = ShyunLinkManager.generateAllFormats(
        'storeDetail',
        {'id': 456},
      );
      
      setState(() {
        _lastResult = 'All Formats:\nHTTPS: ${urls.https}\nCustom: ${urls.custom ?? "Not configured"}';
      });
    } catch (e) {
      setState(() {
        _lastResult = 'Error: $e';
      });
    }
  }

  Future<void> _createShortLink() async {
    try {
      final link = await ShyunLinkManager.createShortLink(
        pageName: 'curationDetail',
        pageType: 'mainBannerCuration',
        pageId: 120,
      );
      
      setState(() {
        _lastResult = link != null ? 'Short link created: $link' : 'Failed to create link';
      });
    } catch (e) {
      setState(() {
        _lastResult = 'Error: $e';
      });
    }
  }

  Future<void> _testHttpsDeepLink() async {
    try {
      // Test HTTPS deep link
      await ShyunLinkManager.processDeepLink('https://cocl.nearound.co/curationDetail?type=mainBannerCuration&id=120');
      
      setState(() {
        _lastResult = 'HTTPS deep link processed successfully';
      });
    } catch (e) {
      setState(() {
        _lastResult = 'Error: $e';
      });
    }
  }

  Future<void> _testCustomSchemeDeepLink() async {
    try {
      // Test custom scheme deep link (legacy compatibility)
      await ShyunLinkManager.processDeepLink('nearound://curationDetail?type=mainBannerCuration&id=120');
      
      setState(() {
        _lastResult = 'Custom scheme deep link processed successfully';
      });
    } catch (e) {
      setState(() {
        _lastResult = 'Error: $e';
      });
    }
  }
}
3
likes
130
points
696
downloads

Publisher

unverified uploader

Weekly Downloads

Streamlined deeplink and short URL management with Clean Architecture. Focused on core functionality - ShyunLinkManager.createShortLink() and deeplink handling with multiple URL format support.

Repository (GitHub)

Topics

#deeplink #url #shortlink #navigation

Documentation

API reference

License

MIT (license)

Dependencies

app_links, dio, flutter, logger, url_launcher

More

Packages that depend on shyun_link

Packages that implement shyun_link