DSwitch is a cli tool that allows you to rapidly switch versions and channels of Dart.
DSwitch is a CLI tool that allows you to rapidly switch between channels and versions of Dart as well as running multiple version of Dart simultaneously.
If you are a flutter user then you are better of using FVM as FVM changes the version of dart embedded in Flutter.
DSwitch is intended to help manage a standalone version of Dart if you are doing things like building CLI applications.
DSwitch can switch between dart channels as well as versions within those channels.
The first time you try to switch between a channel or version, DSwitch will download and cache that channel/version. The next time you switch to the same channel or version the switch is almost instantaneous.
OnePub allows you to privately share Dart packages across your Team and with your customers.
Try it for free and publish your first private package in seconds.
To install DSwitch:
dart pub global activate dswitch
Windows users will need to run with Administrative privileges
DSwitch use a symbolically linked directory that you need to include in your PATH. When you switch versions or channels DSwitch simply re-links the path to the active version/channel.
For this mechanism to work you need to include the DSwitch active path to your PATH environment variable.
The active path is: <HOME>/.dswitch/active
DSwitch maintains a number of 'active' paths which you can uses in your IDE to select a specific version/channel of Dart.
The 'active' path points to the globally active version of Dart.
If you run 'dart' from the command line the 'active' version will be the one that runs.
There are also paths for each channel that points to the current version for that channel (see pinning below).
You can point your IDE at any of the above paths and then use DSwitch to manage the actual version used by a given channel.
Visual Code allows you to specify a per project path to the dart sdk.
You can also target a specific version of Dart without pinning it. The path for a specific Dart version is:
DSwitch support moving between the following channels:
From top to bottom, stable is the most reliable version of Dart and dev is the least reliable/bleeding edge version.
DSwitch uses the following command structure:
dswitch <channel> <action> <data>
dswitch beta install
DSwitch also supports a number of global actions which apply across channels. The command structure for global actions are:
dswitch <action> <data>
The following command switches to the beta channel
dswitch use beta
Installs the given version for the given channel but does not switch to it.
If you don't provide a version then the latest version is installed.
If you pass the --select switch then a menu is displayed with a list of versions available for download.
List all of the locally cached version of Dart for the given channel.
Upgrade the given channel to the latest version for that channel. This command will not switch channels. If the given channel is already active then dswitch will atomicly switch to the new version once it has been installed.
If the channel is pinned the upgrade action will have no affect, a warning will be displayed.
Selects the given version and channel and makes the selected version the current version for the channel.
You can only select a version that is cached locally. Use
dswitch <channel> installto download a version prior to pinning it.
Pinning does NOT activate the channel. Use
dswitch switch <channel>to activate the channel.
If you don't pass a version then a menu will be displayed with the list of locally cached versions for the channel to select from.
Pinning allows you to switch between version within a channel.
Use the unpin command to revert to the latest version for a channel.
Changes the channel to the latest locally cached version for the given channel.
Unpinning a channel does not change the active channel. If the the unpinned channel is the active channel then active channel will revert to the latest locally cached version.
dswitch <channel> upgradeto download the latest version for the channel after unpinning it.
List the status of the channel such as:
- The current version of the channel
- Whether a later version is available for downloading.
- Whether the channel is pinned
- The version no. the channel is pinned to.
Deletes an old dart sdk version from the given channel.
If you pass the
--selectswitch then a menu of the installed versions is displayed. Select one of the versions to delete it.
You may not delete the active version.
Switch between channels. If the channel is not already downloaded, then the latest version for that channel will be downloaded and then DSwitch will switch to that channel.
If the channel is already downloaded then DSwitch will switch to the latest locally cached version for that channel.
Provides the same information as
dswitch <channel> statusbut for every channel.
List all of the locally cached version of Dart for each channel.
If you pass the --archive flag it will list all of the versions available in the Dart online archive.
Last modified 1mo ago