Getting started
Installation
Section titled “Installation”-
To install Solid, run the following command
Terminal window dart pub global activate solid_generator -
Then, add the dependencies needed by running this command in your Flutter project
Terminal window flutter pub add solid_annotations flutter_solidartflutter_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.
-
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_analysisThen in your
analysis_options.yamlfile, add the following lineanalysis_options.yaml include: package:very_good_analysis/very_good_analysis.yamlThis is an example of an
analysis_options.yamlfileanalysis_options.yaml include: package:very_good_analysis/analysis_options.yamlanalyzer:errors:must_be_immutable: ignore # Ignore immutability rule, because Solid generates immutable classes but you write mutable oneslinter:rules:public_member_api_docs: false # Disable documentation requirement for public members
How it works
Section titled “How it works”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.
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 outputThe next chapters expect that you have setup Solid in your Flutter project, created the
sourcefolder and started the command withsolid --watchto auto-generate thelibfolder on file changes.