본문 바로가기
개발/Flutter

Flutter 플러터 URL 주소 열기 간단 구현 url launcher

by SPNK 2022. 12. 25.
반응형
  • 패키지 설치
 

url_launcher | Flutter Package

Flutter plugin for launching a URL. Supports web, phone, SMS, and email schemes.

pub.dev

 

  • 터미널 설치
flutter pub add url_launcher

 

  • android / app / src / main / AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.flutter.example">


    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
    </queries>
    
    
    <application
    ...
    </application
</manifest>

 

  • ios / Runner / Info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
	<string>https</string>
</array>

 

  • 코드 예시
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/material.dart';

class ExamplePage extends StatefulWidget {
  const ExamplePage({Key? key}) : super(key: key);

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
      child: ElevatedButton(
        child: Text(
          "URL 열기",
        ),
        onPressed: () {
          launchUrl(Uri.parse('https://pub.dev/packages/url_launcher'));
        },
      ),
    ));
  }
}

 


참고할만한 글

 

 

Flutter 플러터 백 버튼 무시하기 WillPopScope

코드 예시 Widget build(BuildContext context) { return WillPopScope( onWillPop: () async => false, child: Scaffold(), ); }

parksh3641.tistory.com

 

Flutter 플러터 화면 전환 애니메이션 삭제 간단 사용법 Navigator Animation

코드 예시 Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( child: Text( "메인 화면 이동", ), onPressed: () { Navigator.push( context, PageRouteBuilder( pageBuilder: (BuildContext context, Animation animat

parksh3641.tistory.com

 

반응형

댓글