:::

6-15 加入連結

  1. 安裝 https://pub.dev/packages/url_launcher
  2. 修改 \xxx\android\app\src\main\AndroidManifest.xml,加入:
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
    如:
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="net.tad0616.kidney_disease_diet">
        <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
       <application
            android:label="xxx"
            android:icon="@mipmap/ic_launcher">
            ..略...
        </application>
    
    </manifest>
    

     

  3. 修改 \xxx\ios\Runner\Info.plist,加入:
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>https</string>
        <string>http</string>
    </array>

     

  4. 引入套件
    import 'package:url_launcher/url_launcher.dart';

     

  5. 製作方法:
      void _launchURL(url) async =>
          await canLaunch(url) ? await launch(url) : throw '無法連至 $url';

     

  6. 套用方法:
    GestureDetector(
        onTap: () => _launchURL(
            'https://網址'),
        child: Text(
            '顯示文字或網址',
            style: TextStyle(fontSize: 14.0),
        ),
    ),

     


:::

書籍目錄

展開 | 闔起

快速登入


https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1908%26tbsn%3D42

計數器

今天: 3782378237823782
昨天: 2489248924892489
總計: 8025764802576480257648025764802576480257648025764