.default

Defaults controller is used to set and get key-value pairs used across the application.

Things to know

TIP: The value can be an object.

It is recommended for better support of types by code assistance in IDEs to usegetFrappeDefaultsController()in order to get the instance of FrappeDefaultsController instead of renovation.defaults which is DefaultsController if the backend is Frappè, for instance.

In this guide we will use Frappé as an example and use getFrappeDefaultsController()

.setDefault()

To set the value of a key. Optionally, pass the parent if the key was set under a different parent.

When setting values, they are stringified before adding it in the server.

Input

property

type

required

description

key

String

yes

Key of the value required.

value

String

yes

The value to assign to the key. Can be a Map.

parent

String

no

Specify the parent if the key is duplicated under a different parent. By default uses \_default_ as parent.

Output

RequestResponse<dynamic>

Example

final setDefaultsResponse = await getFrappeDefaultsController()
.setDefaults(key: 'disableSubmission', value: false);

.getDefault() ★

To get the value of a key. Optionally, pass the parent if the key was set under a different parent.

The values are parsed from String when retrieved from the backend.

Input parameters

property

type

required

description

key

String

yes

Key of the value required.

parent

String

no

Can specify the parent if the key is duplicated under a different parent. By default uses '__default' as parent.

Output

RequestResponse<dynamic>

The output since the value can be of many types based on JSON.parse()

Example

final setDefaultsResponse = await getFrappeDefaultsController()
.setDefaults(key: 'disableSubmission', value: false);

In case the key is not found, a successful empty response is returned.