Forms
Documentation for the Forms API for spotube plugins
Spotube provides a Forms API that allows plugin developers to create and manage forms within the Spotube application.
Usage
Following will show a form with 2 text fields and text in between them:
import "module:spotube_plugin" as spotube
spotube.SpotubeForm.show(
"The form page title",
[
{
objectType: "input",
id: "name",
variant: "text",
placeholder: "Enter your name",
required: true,
}.toJson(),
{
objectType: "input",
id: "password",
variant: "password", // This will obfuscate the input
placeholder: "Enter your password",
required: true,
}.toJson(),
{
objectType: "text",
text: "This is some text after the two fields.",
}.toJson(),
]
).then((result) {
// Handle the result
print(result)
})
The method spotube.SpotubeForm.show takes a title and a list of form field declaration map. The map should be, well obviously a Map.
Following are field map properties:
The method spotube.SpotubeForm.show returns a following format:
[
{
"id": "name",
"value": "John Doe"
},
{
"id": "password",
"value": "12345678"
}
]