:::

5. package資源

  1. https://pub.dartlang.org/
  2. 開啟pubspec.yaml在dependencies下加入:
    dependencies:
      flutter:
        sdk: flutter
    
      # The following adds the Cupertino Icons font to your application.
      # Use with the CupertinoIcons class for iOS style icons.
      cupertino_icons: ^0.1.2
      url_launcher: ^5.0.1

    在VS Code中,儲存後就會自動下載(但並不在專案中,而是在flutter的安裝目錄下,例如:C:\tools\flutter\.pub-cache\hosted\pub.dartlang.org)

  3. 安裝使用從installing就有詳細說明,如:https://pub.dartlang.org/packages/url_launcher#-installing-tab-

  4. 完整範例:

    import 'package:flutter/material.dart';
    import 'package:url_launcher/url_launcher.dart';
    
    void main() => runApp(new MyApp());
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new MaterialApp(
          title: '使用工具包',
          home: new Scaffold(
            appBar: new AppBar(
              title: new Text('url_launcher 工具包'),
            ),
            body: new Center(
              child: new RaisedButton(
                onPressed: (){
                  const url='https://schoolweb.tn.edu.tw';
                  launch(url);
                },
                child: new Text('打開集中式校網'),
              ),
            ),
          ),
        );
      }
    }
    

     


:::

書籍目錄

展開 | 闔起

快速登入


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

計數器

今天: 767767767
昨天: 3068306830683068
總計: 8077272807727280772728077272807727280772728077272