5.
package資源
- https://pub.dartlang.org/
- 開啟pubspec.yaml在dependencies下加入:
在VS Code中,儲存後就會自動下載(但並不在專案中,而是在flutter的安裝目錄下,例如:C:\tools\flutter\.pub-cache\hosted\pub.dartlang.org)
-
安裝使用從installing就有詳細說明,如:https://pub.dartlang.org/packages/url_launcher#-installing-tab-
-
完整範例:
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('打開集中式校網'),
),
),
),
);
}
}