发表日期:2018-03 文章编辑:小灯 浏览次数:3419
Flutter官网点击访问
Flutter教程(一)Flutter概览
Flutter教程(二)Flutter安装及运行
pubspec.yaml管理第三方库
在pubspec.yaml中添加第三方库名称及版本号。
例如添加第三方库english_words
dependencies: flutter: sdk: fluttercupertino_icons: ^0.1.0 english_words: ^3.1.0 拉取声明的第三方库到本地工程
flutter packages get
总结:在pubspec.yaml声明需要引用的库,执行命令
flutter packages get进行拉取即可使用。
针对english_words这个第三方库来讲,具体使用参见如下代码
import 'package:flutter/material.dart'; import 'package:english_words/english_words.dart';void main() => runApp(new MyApp());class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { final wordPair = new WordPair.random(); return new MaterialApp( title: 'Welcome to Flutter', home: new Scaffold( appBar: new AppBar( title: new Text('Welcome to Flutter'), ), body: new Center( //child: new Text('Hello World'), // Replace the highlighted text... child: new Text(wordPair.asPascalCase),// With this highlighted text. ), ), ); } }