Aus öffentlichen Paketdaten erstellte Orientierung.
Das json_to_form-Paket für Flutter ermöglicht Entwicklern das dynamische Erstellen von Formularen aus JSON-Konfigurationen. Es vereinfacht die Erstellung interaktiver Benutzeroberflächen, indem es JSON-Strukturen auf Formularfelder wie Texteingaben, Dropdowns und Kontrollkästchen abbildet. Dieses Plugin ist ideal für Anwendungen, die flexible, datengesteuerte Formulare erfordern, ohne UI-Komponenten hartcodieren zu müssen. Es unterstützt mehrere Plattformen, darunter Android, iOS, Web, macOS, Windows und Linux, und sorgt für ein konsistentes Verhalten über Geräte hinweg. Das Paket beschleunigt die Entwicklung und verbessert die Wartbarkeit, indem es die Formularelogik von der UI-Implementierung entkoppelt.
Anwendungsfälle
Dynamische Formularerstellung aus JSON
Konfigurierbare Benutzereingabeschnittstellen
Remote-Formularkonfigurationsaktualisierungen
Plattformübergreifende Formularkonsistenz
Schnellprototyp für Eingabebildschirme
Hauptmerkmale
JSON-getriebene Formularerstellung
Unterstützung für verschiedene Eingabetypen
Plattformunabhängiger Entwurf
Einfache Integration in bestehende Flutter-Apps
Laufzeitformularanpassung
Geeignet für
Entwickler, die datengesteuerte Anwendungen erstellen
Teams, die flexible Formularlayouts benötigen
Anwendungen mit remote Formularverwaltung
Prototyping und MVP-Entwicklung
Apps, die Mehrplattform-Formularunterstützung erfordern
All fields has attribute labelHidden(default false)
Important add key for all field for validation required
TextInput or Input
1.- Types?
Input
Password
Email (has default validation)
TextArea
TextInput
// Example for json string// to start with a default value you can add the value attributeString formString = json.encode({
'fields': [
{
'key': 'inputKey',
'type': 'Input',
'label': 'Hi Group',
'placeholder': "Hi Group flutter",
'required': true
},
{
'key': 'inputKey',
'type': 'Input',
'label': 'Initial Value',
'value': 'Hello''required': true
},
]
});
// Example for json Map// in Map has Attributes validation and decoration//important to receive 2 parameters in function of ValidationStringvalidationExample(field, value) {
if (value.isEmpty) {
return'Please enter some text';
}
returnnull;
}
Map formMap = {
'fields': [
{
'key': 'inputKey',
'type': 'Input',
'label': 'Hi Group',
'placeholder': "Hi Group flutter",
'validator': 'digitsOnly',
'required': true,
'decoration': InputDecoration(
prefixIcon: Icon(Icons.account_box),
border: OutlineInputBorder(),
),
'validation':validationExample,
'keyboardType':TextInputType.number
},
]
};
1.- How can I place validations for my form String?
Excellent :D.
In JsonSchema has attributes (validations, decorations)
Important that each field has to has its unique key