Document how to use the builder options

This commit is contained in:
Simon Binder 2019-08-19 20:02:57 +02:00
parent a2c7b14862
commit fc2d98e07f
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
---
title: "Builder options"
description: >-
Advanced options applied when writing the generated code
---
The `moor_generator` package has some options that control how the
code is generated. Note that, in most cases, the default settings
should be sufficient.
To use the options, create a `build.yaml` file in the root of your project (e.g. next
to your `pubspec.yaml`):
```yaml
# build.yaml. This file is quite powerful, see https://pub.dev/packages/build_config
targets:
$default:
builders:
moor_generator:
options:
generate_private_watch_methods: true
```
At the moment, moor supports these options:
* `generate_private_watch_methods`: boolean. There was a bug in the generator where
[compiled queries]({{<relref "../Using SQL/custom_queries.md">}}) that start with
an underscore did generate a watch method that didn't start with an underscore
(see [#107](https://github.com/simolus3/moor/issues/107)). Fixing this would be
a breaking change, so the fix is opt-in by enabling this option. This flag is
available since 1.7 and will be removed in moor 2.0, where this flag will always
be enabled.
* `write_from_json_string_constructor`: boolean. Adds a `.fromJsonString` factory
constructor to generated data classes. By default, we only write a `.fromJson`
constructor that takes a `Map<String, dynamic>`.