Bearbeiten von „Flutter-Widgets“
Zur Navigation springen
Zur Suche springen
Warnung: Du bist nicht angemeldet. Deine IP-Adresse wird bei Bearbeitungen öffentlich sichtbar. Melde dich an oder erstelle ein Benutzerkonto, damit Bearbeitungen deinem Benutzernamen zugeordnet werden.
Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.
Aktuelle Version | Dein Text | ||
Zeile 8: | Zeile 8: | ||
<pre> | <pre> | ||
List<Widget> = [ | List<Widget> = [ | ||
Col( | Col( children = [ | ||
Row( children: [ | |||
Expanded( | |||
Row( children: [ | child: const Text('Be surprised!'), | ||
Expanded( | ), | ||
child: | const SizedBox(width: 16), | ||
ElevatedButton( | |||
child: Text('Click it'), | |||
onPressed: () => sayHello(), | |||
), | |||
]), | |||
const SizedBox(height: 16), | |||
Row( children: [ | |||
const Expanded (flex: 7, | |||
child: Text('You need help?'), | |||
), | |||
const SizedBox(height: padding), | |||
const Expanded (flex: 2, | |||
child: ElevatedButton( | |||
child: Text('Help me'), | |||
onPressed: () => help(), | |||
), | ), | ||
), | ), | ||
]), | ]), | ||
]), | |||
]; | ]; | ||
</pre> | </pre> | ||
Zeile 55: | Zeile 53: | ||
</pre> | </pre> | ||
= Formular = | |||
= Formular | |||
Jedes Formular benötigt einen '''Key''', der normalerweise im Controller erzeugt/gespeichert wird: | Jedes Formular benötigt einen '''Key''', der normalerweise im Controller erzeugt/gespeichert wird: | ||
Zeile 108: | Zeile 67: | ||
<pre> | <pre> | ||
final form = Form( | final form = Form( | ||
key: controller.formKey, | key: controller.formKey, | ||
Zeile 117: | Zeile 72: | ||
children: [ | children: [ | ||
TextFormField( | TextFormField( | ||
validator: checkInt, | validator: checkInt, | ||
onSaved: (input) => controller. | onSaved: (input) => controller.controllerData = input, | ||
controller: | controller: , | ||
), | ), | ||
]), | ]), | ||
Zeile 134: | Zeile 81: | ||
void store(controller, String input){ | void store(controller, String input){ | ||
if (controller, formKey.currentState?.validate() ?? false) { | |||
controller.formKey.currentState?.save(); | |||
} | |||
} | } | ||
</pre> | </pre> | ||