SettingsTab.dart (2445B)
1 import 'package:flutter/cupertino.dart'; 2 import 'package:flutter/material.dart'; 3 4 class SettingsTab extends StatefulWidget { 5 @override 6 SettingsTabState createState() => SettingsTabState(); 7 } 8 9 class SettingsTabState extends State<SettingsTab> 10 with AutomaticKeepAliveClientMixin<SettingsTab> { 11 final _formKey = GlobalKey<FormState>(); 12 13 @override 14 Widget build(BuildContext context) { 15 super.build(context); 16 17 return Padding( 18 padding: EdgeInsets.all(16), 19 child: Form( 20 key: _formKey, 21 child: Column( 22 children: <Widget>[ 23 Text("Profil"), 24 TextFormField( 25 decoration: InputDecoration(hintText: "Nickname"), 26 // The validator receives the text that the user has entered. 27 validator: (value) { 28 if (value.isEmpty) { 29 return 'Please enter a nickname'; 30 } 31 return null; 32 }, 33 ), 34 TextFormField( 35 decoration: InputDecoration(hintText: "E-Mail"), 36 // The validator receives the text that the user has entered. 37 validator: (value) { 38 if (value.isEmpty) { 39 return 'Please enter an E-Mail'; 40 } 41 return null; 42 }, 43 ), 44 // TODO add checkboxes 45 TextFormField( 46 decoration: InputDecoration(hintText: "Dein Link"), 47 // The validator receives the text that the user has entered. 48 validator: (value) { 49 if (value.isEmpty) { 50 return 'Please enter an E-Mail'; 51 } 52 return null; 53 }, 54 ), 55 RaisedButton( 56 onPressed: () { 57 // Validate returns true if the form is valid, otherwise false. 58 if (_formKey.currentState.validate()) { 59 // If the form is valid, display a snackbar. In the real world, 60 // you'd often call a server or save the information in a database. 61 62 Scaffold.of(context) 63 .showSnackBar(SnackBar(content: Text('Processing Data'))); 64 65 // TODO do stuff 66 } 67 }, 68 child: Text('Speichern'), 69 ), 70 ], 71 ), 72 ), 73 ); 74 } 75 76 @override 77 bool get wantKeepAlive => true; 78 }