Skip to content

Getting started

  1. To install Solid, run the following command

    Terminal window
    dart pub global activate solid_generator
  2. Then, add the dependencies needed by running this command in your Flutter project

    Terminal window
    flutter pub add solid_annotations flutter_solidart

    flutter_solidart is the state management library used by Solid, but you don’t have to learn how to use it, Solid will generate all the boilerplate code for you.

  3. I’d also suggest installing the very_good_analysis package to get amazing linting rules for your Flutter project.

    Terminal window
    flutter pub add dev:very_good_analysis

    Then in your analysis_options.yaml file, add the following line

    analysis_options.yaml
    include: package:very_good_analysis/very_good_analysis.yaml

    This is an example of an analysis_options.yaml file

    analysis_options.yaml
    include: package:very_good_analysis/analysis_options.yaml
    analyzer:
    errors:
    must_be_immutable: ignore # Ignore immutability rule, because Solid generates immutable classes but you write mutable ones
    linter:
    rules:
    public_member_api_docs: false # Disable documentation requirement for public members

The code you write is the source of truth, and Solid generates the boilerplate code needed to make the app working.

There is an important difference between writing normal Flutter code and writing Solid code: In Flutter, the lib folder is the source of truth, while in Solid, the source folder is the source of truth.

You never have to edit the lib folder manually, as it is generated by Solid.

I decided not to use the lib folder directly because I don’t want to touch the original files, but I wanted to keep the same naming and structure, without adding complexity to you like part files or similar.

I wanted to use lib as the input folder, but flutter build doesn’t allow building (as far as I know) an app from a different folder than lib.

In addition, Solid is not a common generator because it transpiles your existing code to an optimized version of it.

Terminal window
Usage: solid [options]
-s, --source Source directory to read from
(defaults to "source")
-o, --output Output directory to write to
(defaults to "lib")
-w, --[no-]watch Watch for file changes and auto-regenerate
-c, --[no-]clean Deletes the build cache. The next build will be a full build.
-v, --[no-]verbose Verbose output
-h, --[no-]help Show this help message
Examples:
solid # Basic transpilation
solid --watch # Watch mode
solid --clean --verbose # Clean build with verbose output

The next chapters expect that you have setup Solid in your Flutter project, created the source folder and started the command with solid --watch to auto-generate the lib folder on file changes.