:lang dart

paint ui and not much else

1. Description

Dart is a client-optimized language by Google for fast apps on any platform. It is fast and optimized for UI, famous for the Flutter framework, also made by Google. Both Flutter and Dart are free and open-source.

This module wraps dart-mode, with LSP features like code completion for .dart files, syntax highlighting, debugging, closing labels, etc.

1.2. Module flags

Add flutter integration and some sane defaults for Flutter development along with hover for desktop development.
Enable LSP support for dart-mode. Requires :tools lsp and a langserver (supports lsp-dart).

1.4. Hacks

No hacks documented for this module.

2. Prerequisites

Make sure that the Dart SDK is on your $PATH, and if using Flutter, make sure the Flutter binary is on your $PATH as well.

2.1. Installing Dart SDK

Before starting note that Flutter SDK will have a version of Dart. Therefore, there is no need to install Dart. If you want to use Flutter just see the next part.

The stable version of the SDK is in most major distributions repositories. If you find it necessary to install any other version or build from source, please refer to the official website at: https://dart.dev/get-dart

  • On Debian (also Ubuntu and its derivations):

    $ sudo apt-get install dart
  • On Arch Linux (and derivations like Manjaro):

    $ sudo pacman -S dart
  • On macOS:

    $ brew tap dart-lang/dart
    $ brew install dart
  • On NixOS:

    $ nix-env -iA nixpkgs.dart

2.2. Installing Flutter SDK

Due to complications with permissions, it is suggested not to use AUR or any automatic installation tools for Flutter SDK.

On any system just run the following commands to install Flutter, once you have met dependencies named on the site:

$ git clone https://github.com/flutter/flutter --branch stable # to download Flutter
$ export PATH="$PATH:$(pwd)/flutter/bin" # to add it to PATH
$ flutter doctor # for Dependency check and further instructions

3. Usage

  • Syntax highlighting and formatting for .dart files provided by LSP
  • Auto import
  • Widget guide lines for Flutter
  • Closing labels for constructors
  • Run tests interactively
  • Outline support via lsp-treemacs
  • Emacs functions for running and debugging Flutter projects

4. Configuration

4.1. Dart & Flutter

On Linux, the installers for Dart and Flutter use the /opt directory, and this module assumes that. However, you may set lsp-dart-sdk-dir to your Dart install directory and flutter-sdk-path to you flutter SDK folder, to make sure LSP can find the language server included with the Dart SDK.

Alternatively, these variables shouldn’t be necessary if you just include Dart and Flutter on your PATH variable.

4.2. Android

You will also need to setup your system for Android development if you intend to use Flutter to develop mobile applications. Refer to your distributions package manager for details. In most distributions the /opt/android-sdk directory is used, and you might have to change some permissions in this directory since it’s owned by root. The Arch Linux wiki has a great guide on this here.

4.3. Flutter mobile development on desktop

Hover is an application that can run Flutter mobile apps on your desktop, this makes the mobile development a lot easier without the need to setup an Android emulator.

5. Troubleshooting

  • On new installs to the /opt directory, you will likely need to edit the permissions of the /opt/dart-sdk and /opt/flutter directories (not to mention the Android SDK, as discussed above).

6. TODO Appendix

This module has no appendix yet. Write one?