WSLApi class

This class is used to interact with WSL. It contains all the functions needed to interact with WSL based on Process.run and Process.start. Most functions will return the UTF8 converted stdout of the process.

Constructors

WSLApi()

Properties

hashCode int
The hash code for this object.
read-onlyinherited
lastDistroList Instances
read / write
resultQueue List<String>
read / write
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

cleanup(String distribution) Future<String>
Clean up WSL distros. Exporting, deleting, and importing.
copy(String distribution, String newName) Future<String>
Copy a WSL distro by name
copyVhd(String name, String newName) Future<String>
Copy a WSL distro by name and vhd
create(String distribution, String filename, String installPath, dynamic status(String), {bool image = false}) Future
Import a WSL distro by name
editConfig() → void
Open wslconfig file
exec(String distribution, List<String> cmds) Future<List<int>>
Executes a command in a WSL distro. passwd will open a shell
execCmdAsRoot(String distribution, String cmd) Future<String>
Executes a command in a WSL distro and returns the output
execCmds(String distribution, List<String> cmds, {String? user, required dynamic onMsg(String), required Function onDone, bool showOutput = true}) Future<List<int>>
Executes a command list in a WSL distro
export(String distribution, String location) Future<String>
Export a WSL distro by name
getCurrentOutput() String
Get the current cached output
getDownloadable(String repo, dynamic onError(String)) Future<List<String>>
Returns list of downloadable WSL distros
getSize(String distroName) String?
Get distro size of distroName a string with a GB suffix. Returns null if size is 0. e.g. "2.00 GB"
import(String distribution, String installLocation, String filename, {bool isVhd = false}) Future<String>
Import a WSL distro by name
install(String distribution) Future<String>
Install a WSL distro by name
installWSL() → void
Install WSL
list(bool showDocker) Future<Instances>
Returns list of WSL distros
listRunning() Future<List<String>>
Returns list of WSL distros
mkRootDir({String path = defaultPath}) → void
Create directory
move(String distro, String newPath) Future<String>
Move WSL distro to another location by distro and newPath. Returns ProcessResult of the command.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openBashrc(String distribution) Future<String>
Open bashrc with notepad from WSL
readConfig() Future<Map<String, String>>
Read wslconfig file
remove(String distribution) Future<String>
Remove a WSL distro by name
restart() Future<String>
Restart WSL
runCmds(String distribution, List<String> cmds, {String? user}) Future<Process>
Executes a command list in a WSL distro and open a terminal
setConfig(String parent, String key, String value) → void
Set wslconfig setting
setSetting(String distro, String parent, String key, String value) Future<bool>
Change setting in wsl.conf with key and value
shutdown() Future<String>
Shutdown WSL
start(String distribution, {String startPath = '', String startUser = '', String startCmd = ''}) → void
Start a WSL distro by name
startExplorer(String distribution) → void
Start Explorer
startVSCode(String distribution, {String path = ''}) → void
Start VSCode
startWindowsTerminal(String distribution) → void
Start Windows Terminal
stop(String distribution) Future<String>
Stop a WSL distro by name
toString() String
A string representation of this object.
inherited
utf8Convert(List<int> bytes) String
Convert bytes to human readable string while removing non-ascii characters
writeConfig(String text) → void
Write wslconfig file

Operators

operator ==(Object other) bool
The equality operator.
inherited