1-1 dart开发环境搭建 | dart从入门到放弃

in #cn5 years ago (edited)

dart-logo-for-shares.jpg

上一篇:什么是dart
下一篇:1-2 DART基本数据类型

1.1.1 DART SDK安装

DART SDK包含了DART的基本运行环境,以及常用的库和命令行工具。

首先,我们要安装dart的sdk。
dart是跨平台的,我们可以很容易的在windows,linux和mac下安装dart sdk。

在windows下,我们可以用choco来安装。

chocolatey的安装看这里-》https://chocolatey.org/install
官方写得很啰嗦。
如果windows10的话,右键(注意是右键)点击左下角windows徽标,选择windows powershell(管理员)模式。
然后,复制并执行下面这一行代码即可自动安装chcolatey。因为都是脚本,可能需要在弹出的防火墙提示里选择允许。

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

安装好,hocolatey以后,用如下代码安装dart sdk

C:\> choco install dart-sdk

当然了,大部分人在windows下,还是习惯用安装包来安装程序。Dart SDK的windows安装包在这里 -》http://www.gekorm.com/dart-windows/
下载并安装STABLE版即可。
为什么我一开始不提这个安装包呢?因为这个安装包居然需要翻墙才能安装。What a fuck!~

在linux(debian/ubuntu)下,我们可以用apt-get来安装


$ sudo apt-get update
$ sudo apt-get install apt-transport-https
$ sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
$ sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'

$ sudo apt-get update
$ sudo apt-get install dart

Mac下,我们直接用homebrew来安装

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

另外,我们可以在如下官方地址,获得更详细和更新的安装指南
https://webdev.dartlang.org/tools/sdk#install

1.1.2 DART IDE(编辑器)安装

运行环境安装好了以后,我们需要安装我们开发用的编辑器。
目前编写dart较为流行的编辑器主要是IDEA和visual studio code。
他们也都是跨平台可用的。

IDEA安装

idea的官方安装地址-> http://www.jetbrains.com/idea/download/
安装很简单,一路默认设置即可。注册问题,请自行解决。
或者,您也可以使用后面推荐的visual studio code。

idea安装好了以后,我们还需要安装对应的dart插件。
在启动界面右下角找到configure,选择plugins。
然后在弹出的搜索框里搜索dart。安装Dart Languages插件。

visual studio安装

微软的东西向来不被非微软系程序员待见。但客观点说,visual studio code确实是最近几年最良心,最被人称道的产品之一。居然还是免费的。

visual studio code的官方安装地址-> https://code.visualstudio.com/
安装也是一路默认值,安装完以后同样要安装dart插件。
安装好以后,打开visual studio code,最左边一排按钮,最下面那个就是扩展商店。
搜索dart安装如下图所示的第一个插件,即可。

1.1.3 Hello world!

例行公事的Hello world!
一个最简单的Hello world程序如下所示。大家可以自己新建一个hello_world.dart文件尝试执行一下。直接执行dart hello_world.dart即可

void main(){
  print("Hello World!");
}

上一篇:什么是dart
下一篇:1-2 DART基本数据类型

Sort:  

Congratulations @liuzhixiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 900 upvotes. Your next target is to reach 1000 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Saint Nicholas challenge for good boys and girls

Support SteemitBoard's project! Vote for its witness and get one more award!

partiko里的标题怎么这么小。。。。。

Posted using Partiko iOS

Congratulations @liuzhixiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 500 upvotes. Your next target is to reach 600 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @liuzhixiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 600 upvotes. Your next target is to reach 700 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Saint Nicholas challenge for good boys and girls

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @liuzhixiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 700 upvotes. Your next target is to reach 800 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Saint Nicholas challenge for good boys and girls

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @liuzhixiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 800 upvotes. Your next target is to reach 900 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Saint Nicholas challenge for good boys and girls

Support SteemitBoard's project! Vote for its witness and get one more award!

聚贤阁群友互动,您中奖了! 聚贤阁小乐透传送门

Congratulations @liuzhixiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 1000 upvotes. Your next target is to reach 1250 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @liuzhixiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 1250 upvotes. Your next target is to reach 1500 upvotes.

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @liuzhixiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 1500 upvotes. Your next target is to reach 1750 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Christmas Challenge - Send a gift to to your friends

Support SteemitBoard's project! Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.032
BTC 63423.66
ETH 3077.69
USDT 1.00
SBD 3.87