flutter学习笔记
安装环境Mac终端
镜像服务器地址配置
1. export PUB_HOSTED_URL=https://pub.flutter-io.cn
2. export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
3. ./flutter doctor
环境配置 over
vscode配置flutter 环境 安装运行调试的插件
1.Flutter
2.Flutter Widget Snippets
运行run flutter doctor 检测是否能用
//创建app
flutter create myflutter
安装第三方包
pubspec.yaml配置文件
//第三方
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
english_words: ^3.1.0
++++++
保存后自动link完就可以在需要的地方引用
import 'package:english_words/english_words.dart';
class RandomWords extends StatefulWidget {
@override
RandomWordsState createState() => new RandomWordsState();
}
class RandomWordsState extends State {
@override // 新增代码片段 - 开始 ...
Widget build(BuildContext context) {
//使用随机单词的第三方库
final WordPair wordPair = new WordPair.random();
return new Text(wordPair.asPascalCase);
} // ... 新增的代码片段 - 结束
}
继承自 StatelessWidget 状态不可变 无状态控件
网友评论