https://pub.dev/packages/url_launcher
url_launcher | Flutter Package
Flutter plugin for launching a URL. Supports web, phone, SMS, and email schemes.
pub.dev
Flutter에서 앱 내에 특정 버튼 또는 텍스트에 URL 링크를 설정하여 폰 내에 다른 브라우저에서 실행하는 방법 입니다.
사용법은 굉장히 심플합니다.
설치 방법
dependencies:
url_launcher: ^5.7.10
설정
1. Android ( AndroidManifest.xml 내 추가 )
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
2.iOS ( info.plist 내 추가)
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
</array>
사용법
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
const String _url = 'https://flutter.dev';
void main() => runApp(
const MaterialApp(
home: Material(
child: Center(
child: RaisedButton(
onPressed: _launchURL,
child: Text('Show Flutter homepage'),
),
),
),
),
);
void _launchURL() async {
if (!await launch(_url)) throw 'Could not launch $_url';
}
'Flutter(플러터) > pub.dev' 카테고리의 다른 글
build_runner (0) | 2021.12.14 |
---|---|
json_serializable (0) | 2021.12.14 |
retrofit (레트로핏) (0) | 2021.12.14 |
댓글