使用第三方库
官方例子使用英文名字随机库
在pubspec.yaml中增加库名字和版本号就可以
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
# 增加这行
english_words: ^4.0.0
并在pubspec.yaml文件右键。下载库就可以。也可以使用命令在工程目录运行:
flutter pub get
官方例子使用英文名字随机库
在pubspec.yaml中增加库名字和版本号就可以
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
# 增加这行
english_words: ^4.0.0
并在pubspec.yaml文件右键。下载库就可以。也可以使用命令在工程目录运行:
flutter pub get
增加环境变量
Win下在系统设置环境变量分别增加下面两个变量
PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter
Linux 或 Mac下增加
export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter
这样使用
Flutter pub get
或者在VSCode下载包时就可能直接下载。不需要VPN