Date
May. 19th, 2024
 
2024年 4月 12日

Post: Dart Primer 001 : Hello, world!

Dart Primer 001 : Hello, world!

Published 12:05 May 17, 2018.

Created by @ezra. Categorized in #Programming, and tagged as #Dart.

Source format: Markdown

Table of Content

今天开始一起来学习一下 Dart 语言。

安装

首先第一步来 安装 Dart, 以 macOS 为例:

homebrew

先来安装 homebrew, 然后执行:

$ brew tap dart-lang/dart
$ brew install dart

如果你要安装开发者版本, 使用 --devel 选项:

$ brew install dart --devel

如果你已经安装过了, 可以通过这个指令来更新新版本:

$ brew upgrade dart

IDE

早期官方推荐的 Dart Editor 已经弃用, 现在你可以使用 WebStormAtom, 当然, 你需要安装 Dart 相关插件。

Hello, word!

现在, 我们来编写第一个程序吧。

main.dart 中写入以下代码:

void main() {
  print("Hello, world!");
}

需要指出的是, Dart 有两种运行模式:

  • 检查模式 (checked): 进行类型检查,如果发现实际类型与声明或期望的类型不匹配就报错
  • 生产模式 (production): 不进行类型检查,忽略声明的类型信息,忽略 assert 语句

如果你是用 WebStorm, 可以在 Run => Edit Configurations 中对运行模式进行修改。

Pinned Message
HOTODOGO
I'm looking for a SOFTWARE PROJECT DIRECTOR / SOFTWARE R&D DIRECTOR position in a fresh and dynamic company. I would like to gain the right experience and extend my skills while working in great teams and big projects.
Feel free to contact me.
For more information, please view online résumé or download PDF
本人正在寻求任职 软件项目经理 / 软件技术经理 岗位的机会, 希望加⼊某个新鲜⽽充满活⼒的公司。
如有意向请随时 与我联系
更多信息请 查阅在线简历下载 PDF