Advertisement
wildanfuady

Text Field Example

Oct 13th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:grouped_buttons/grouped_buttons.dart';
  3.  
  4. class TextFieldExample extends StatelessWidget {
  5.  
  6. final _formKey = GlobalKey<FormState>();
  7. @override
  8. Widget build(BuildContext context) {
  9. return Scaffold(
  10. appBar: AppBar(
  11. title: Text('Form Sample'),
  12. ),
  13. body: Form(
  14. key: _formKey,
  15. child: Padding(
  16. padding: const EdgeInsets.all(8.0),
  17. child: Column(
  18. children: <Widget>[
  19. TextFormField(
  20. textInputAction: TextInputAction.next,
  21. // focusNode: _nameFocus,
  22. decoration: const InputDecoration(
  23. icon: Icon(Icons.person),
  24. labelText: 'Nama Siswa *',
  25. hintText: 'Masukan nama siswa',
  26. ),
  27. ),
  28. TextFormField(
  29. textInputAction: TextInputAction.next,
  30. // focusNode: _nameFocus,
  31. decoration: const InputDecoration(
  32. icon: Icon(Icons.phone),
  33. labelText: 'Telp *',
  34. hintText: 'Masukan no telp',
  35. ),
  36. ),
  37. TextFormField(
  38. textInputAction: TextInputAction.next,
  39. // focusNode: _nameFocus,
  40. decoration: const InputDecoration(
  41. icon: Icon(Icons.email),
  42. labelText: 'Email *',
  43. hintText: 'akun@emailanda.com',
  44. ),
  45. ),
  46. ],
  47. ),
  48. ),
  49. ),
  50. floatingActionButton: FloatingActionButton(
  51. child: Icon(Icons.save),
  52. onPressed: () {
  53. // Validate returns true if the form is valid, or false
  54. // otherwise.
  55. if (_formKey.currentState.validate()) {
  56. // If the form is valid, display a Snackbar.
  57. Scaffold.of(context)
  58. .showSnackBar(SnackBar(content: Text('Processing Data')));
  59. }
  60. },
  61. ),
  62. );
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement