This tutorial shows the steps to install and set up Dart on a Windows machine.

How to setup and install Dart in Windows

First, Make sure that the choco command is working or not. Next, Open `Microsoft PowerShell with Administrator permission.

Type command “choco” in powershell

PS C:\> choco
Chocolatey v0.10.15
Please run 'choco -?' or 'choco <command> -?' for help menu.

It gives version number if choco command gives version number.

If choco is not installed Please install choco.

If you are installing the first time, Please run the below command.

choco install dart-sdk

Here is an installation logs

PS C:\WINDOWS\system32> choco install dart-sdk
Chocolatey v0.10.15
Installing the following packages:
dart-sdk
By installing you accept licenses for the packages.

dart-sdk v2.16.1 [Approved]
dart-sdk package files install completed. Performing other installation steps.
The package dart-sdk wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): yes

PATH environment variable does not have C:\tools\dart-sdk\bin in it. Adding...
PATH environment variable does not have C:\Users\Kiran\AppData\Roaming\Pub\Cache\bin in it. Adding...
Downloading dart-sdk 64 bit
  from 'https://storage.googleapis.com/dart-archive/channels/stable/release/2.16.1/sdk/dartsdk-windows-x64-release.zip'
Progress: 100% - Completed download of C:\Users\Kiran\AppData\Local\Temp\dart-sdk\2.16.1\dartsdk-windows-x64-release.zip (185.7 MB).
The download of dartsdk-windows-x64-release.zip (185.7 MB) was completed.
Hashes match.
Extracting C:\Users\Kiran\AppData\Local\Temp\dart-sdk\2.16.1\dartsdk-windows-x64-release.zip to C:\tools...
C:\tools
Environment Vars (like PATH) have changed. Close/reopen your shell to
 see the changes (or in powershell/cmd.exe just type `refreshenv`).
 The installation of dart-sdk was successful.
  Software installed to 'C:\tools'

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Enjoy using Chocolatey? Explore more amazing features to take your
experience to the next level at
 https://chocolatey.org/compare

Once installation is done, It is installed to the c:\tools folder.

It contains the dart-sdk folder.

Next, add environment variables

if you don’t run PowerShell in administrator permission, It throws below error dart-sdk (exited 1) - dart-sdk not installed. An error occurred during installation: Access to the path ‘C:\ProgramData\chocolatey\lib\dart-sdk’ is denied.

PS C:\> choco install dart-sdk
Chocolatey v0.10.15
Chocolatey detected you are not running from an elevated command shell
 (cmd/Powershell).

 You may experience errors - many functions/packages
 require admin rights. Only advanced users should run choco w/out an
 elevated shell. When you open the command shell, you should ensure
 that you do so with "Run as Administrator" selected. If you are
 attempting to use Chocolatey in a non-administrator setting, you
 must select a different location other than the default install
 location. See
 https://chocolatey.org/install#non-administrative-install for details.


 Do you want to continue?([Y]es/[N]o): yes

Installing the following packages:
dart-sdk
By installing you accept licenses for the packages.
dart-sdk not installed. An error occurred during installation:
 Access to the path 'C:\ProgramData\chocolatey\lib\dart-sdk' is denied.
dart-sdk package files install completed. Performing other installation steps.
The installation of dart-sdk was NOT successful.
dart-sdk not installed. An error occurred during installation:
 Access to the path 'C:\ProgramData\chocolatey\lib\dart-sdk' is denied.

Chocolatey installed 0/1 packages. 1 package failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - dart-sdk (exited 1) - dart-sdk not installed. An error occurred during installation:
 Access to the path 'C:\ProgramData\chocolatey\lib\dart-sdk' is denied.

Next, Add environment variables with dart-sdk path

Following are steps required t

  • In the windows search, Type env and select “Edit the system environment variables” windows-environment-variables.png
  • It opens the System Properties window
  • Select Environment Variables
  • In the User variables, Select Path and click on Edit, It opens the Edit environment variables window
  • Click on the New button
  • Add C:\tools\dart-sdk\bin value and select Ok
  • Close all windows by selecting an apply or ok button
  • Close all terminals or command prompt windows

Now, open the command line and type the dart command with the --version option

C:\>dart --version
Dart SDK version: 2.16.1 (stable) (Tue Feb 8 12:02:33 2022 +0100) on "windows_x64"

It gives a version installed on the machine.