Introduction to Dart
Because flutter is written in dart language, before learning flutter, you need to learn the Dart language first.
Dart is a computer language developed by Google. It can be used in the development of web, server, mobile applications, and Internet of Things. Dart was born in 2011, claiming to replace JavaScript, but it has been tepid in the past few years, knowing that the emergence of flutter has been again valued by the public.
Official website: https://dart.dev/
Dart installation
Because the local computer is a Windows computer, the installation and explanation are mainly based on the Windows platform.
Official installation instructions: https://dart.dev/get-dart#install-using-a-setup-wizard
official website provides two installation methods, we first install according to the second method, exe file installation
opens the download address, As shown in the figure below, we choose the stable version
and install the exe file after downloading.
If you use the exe file to install the following installation steps, there is no problem, you can skip
the things that should have been very easy, but it won't work on a computer with a good firewall
? ? exe can not be installed, can not stand birds, had to install in the first way
To install using Chocolatey:
1) Install Chocolatey
choco -?
First, we open the windows powershell and see if choco is installed. If it is not installed, first install choco. The
installation steps are also clearer on the official website:
first execute the following command:
Get-ExecutionPolicy
If it does not return to Restricted, just go to the next step, if it is, then execute the command against the official document, I did not return here, so I went directly to the next step
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Direct implementation of this order, the execution is completed, there will be the following output
execute the following command to check whether the installation was successful
choco -?
2) Install dart sdk
Excuting an order:
choco install dart-sdk
Just wait for the installation. After the installation is successful, as shown in the following figure:
students who install through exe can continue to go down from here.
Restart the windows power shell window and enter the command:
dart --version
You can see the version of
dart. Here, the dart installation is successful
VSCode configuration dart
vscode download address: https://code.visualstudio.com/Download
exe installation, you can use the default installation
Install dart plugin
Install Code Runner plugin
Code Runner is used to run our files. After the
installation is complete, restart vscode
dart first experience
Click open folder here to add the folder where you store the dart test code. After opening it, as shown in the figure below:
Then create a dart file:
Let's run the program below:
Click Run to find the following error:
[Running] dart "d:\work\workspace\dart\dartdemo\index.dart"
Dart_LoadScriptFromKernel: The binary program does not contain 'main'.
[Done] exited with code=253 in 0.298 seconds
Follow the steps below:
Return to the project directory: the
launch.json file will appear, we change the main.dart in the program to index.dart
and then return to index.dart, right-click again to execute the run code, you will find hello dart can Output correctly
[Running] dart "d:\work\workspace\dart\dartdemo\index.dart"
hello dart
[Done] exited with code=0 in 0.27 seconds