Skip to content

Settings

Using Settings

To add settings to your plugin, you need to create a file called SettingsTemplate.yaml. You can read more about it in the documentation. For now, let’s create a simple settings file for specifying the city we want to look up the weather for.

SettingsTemplate.yaml
body:
- type: input
attributes:
name: city
label: "Enter the city you'd like to look up the weather for:"
defaultValue: New York

That’s it, now your settings are available in the Plugins tab in Flow Launcher settings:

Settings UI demo

You can access them using the settings property of your class:

@FlowPlugin.Class
export class MyPlugin extends FlowPlugin {
@FlowPlugin.Init
myInitMethod() {
this.settings.city; // "New York"
}
}

Specifying Settings Type

You might want to specify the structure of the settings object so that you can get suggestions from your IDE when working with it. If you don’t want to, you can skip this section. You can specify the type like this:

/**
* @typedef {object} MySettings
* @property {string} city
*/
/** @extends {FlowPlugin<MySettings>} */
@FlowPlugin.Class
export class MyPlugin extends FlowPlugin {
}