:::

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%3Ftbsn%3D42%26tbdsn%3D1908

計數器

今天: 2050205020502050
昨天: 4038403840384038
總計: 5566013556601355660135566013556601355660135566013