Dart:修订间差异
跳到导航
跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
(→範例) |
(→外部連結) |
||
(未显示同一用户的3个中间版本) | |||
第32行: | 第32行: | ||
dependencies: | dependencies: | ||
http: ^1.2.1 | http: ^1.2.1 | ||
</syntaxhighlight> | |||
然後就可以更新: | |||
<syntaxhighlight lang="bash"> | |||
dart pub get | |||
</syntaxhighlight> | </syntaxhighlight> | ||
第37行: | 第43行: | ||
<syntaxhighlight lang="dart"> | <syntaxhighlight lang="dart"> | ||
void main() { | import 'package:http/http.dart' as http; | ||
print(' | |||
void main(List<String> arguments) async { | |||
var url = Uri.https('www.google.com', 'robots.txt'); | |||
var response = await http.get(url); | |||
print('Response status: ${response.statusCode}'); | |||
print('Response body: ${response.body}'); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
第49行: | 第60行: | ||
* {{Official|https://dart.dev/}} {{en}} | * {{Official|https://dart.dev/}} {{en}} | ||
* [https://dart.dev/language Introduction to Dart] {{en}} | |||
* [https://dart.dev/codelabs/dart-cheatsheet Dart cheatsheet codelab] {{en}} | |||
[[Category:程式語言]] | [[Category:程式語言]] |
2024年3月13日 (三) 09:58的最新版本
Dart是一个程式语言。
安装
wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg; echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list; sudo apt update; sudo apt install -y dart; sudo apt clean
范例
先初始化目录:
dart create foo
然后进到foo/
里面把Git环境先弄起来,并且把预设产生出来的初始环境先包进去:
cd foo; git init .; git add .; git commit -av -m 'Init by "dart create foo".'
然后就可以执行测试:
dart run
接着就可以开始修改了,这边是先在pubspec.yaml
里面加上http
:
dependencies:
http: ^1.2.1
然后就可以更新:
dart pub get
然后改bin/foo.dart
:
import 'package:http/http.dart' as http;
void main(List<String> arguments) async {
var url = Uri.https('www.google.com', 'robots.txt');
var response = await http.get(url);
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
}
相关连结
外部链接
- 官方网站 (英文)
- Introduction to Dart (英文)
- Dart cheatsheet codelab (英文)