Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.80 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4. runApp(MaterialApp(home: Home()));
  5. }
  6.  
  7. class Home extends StatefulWidget {
  8. @override
  9. _HomeState createState() => _HomeState();
  10. }
  11.  
  12. class _HomeState extends State<Home> {
  13. TextEditingController pedidoController = TextEditingController();
  14. TextEditingController nomeController = TextEditingController();
  15. TextEditingController mesaController = TextEditingController();
  16. TextEditingController descricaoController = TextEditingController();
  17.  
  18. String _infoText = "Confirmar";
  19.  
  20. void _resetfields() {
  21. pedidoController.text = "";
  22. nomeController.text = "";
  23. mesaController.text = "";
  24. descricaoController.text = "";
  25.  
  26. setState(() {
  27. _infoText = "Confirmar";
  28. });
  29. }
  30.  
  31. void _relatorio() {
  32. setState(() {
  33. print(pedidoController.text);
  34. print(nomeController.text);
  35. print(mesaController.text);
  36. print(descricaoController);
  37. _infoText = "Pedido confirmado!";
  38. });
  39. }
  40.  
  41. @override
  42. Widget build(BuildContext context) {
  43. return Scaffold(
  44. appBar: AppBar(
  45. title: Text("Comanda"),
  46. centerTitle: true,
  47. backgroundColor: Colors.orangeAccent,
  48. actions: <Widget>[
  49. IconButton(
  50. icon: Icon(Icons.refresh),
  51. onPressed: _resetfields,
  52. )
  53. ],
  54. ),
  55. backgroundColor: Colors.white,
  56. body: Stack(
  57. children: <Widget>[
  58. Image.asset(
  59. "images/back.jpg",
  60. fit: BoxFit.fill,
  61. height: 1000.0,
  62. ),
  63. Form(
  64. child: SingleChildScrollView(
  65. padding: EdgeInsets.fromLTRB(15.0, 20.0, 15.0, 0.0),
  66. child: Column(
  67. children: <Widget>[
  68. Container(
  69. padding: EdgeInsets.only(bottom: 10.0),
  70. child: TextField(
  71. keyboardType: TextInputType.number,
  72. decoration: InputDecoration(
  73. labelText: "Número do pedido",
  74. border: OutlineInputBorder(
  75. borderRadius: BorderRadius.circular(20.0)),
  76. labelStyle: TextStyle(
  77. color: Colors.white, fontSize: 20.0,)),
  78. controller: pedidoController,
  79. ),
  80. ),
  81. Container(
  82. padding: EdgeInsets.only(bottom: 10.0),
  83. child: TextFormField(
  84. keyboardType: TextInputType.text,
  85. decoration: InputDecoration(
  86. border: OutlineInputBorder(
  87. borderRadius: BorderRadius.circular(32.0)),
  88. labelText: "Nome:",
  89. labelStyle: TextStyle(
  90. color: Colors.white, fontSize: 20.0)),
  91. controller: nomeController,
  92. ),
  93. ),
  94. Container(
  95. padding: EdgeInsets.only(bottom: 10.0),
  96. child: TextField(
  97. keyboardType: TextInputType.number,
  98. decoration: InputDecoration(
  99. labelText: "Numero da mesa:",
  100. border: OutlineInputBorder(
  101. borderRadius: BorderRadius.circular(32.0)),
  102. labelStyle: TextStyle(
  103. color: Colors.white, fontSize: 20.0)),
  104. controller: mesaController,
  105. ),
  106. ),
  107. Container(
  108. padding: EdgeInsets.only(bottom: 10.0),
  109. child: TextFormField(
  110. keyboardType: TextInputType.text,
  111. decoration: InputDecoration(
  112. labelText: "Descrição do pedido:",
  113. border: OutlineInputBorder(
  114. borderRadius: BorderRadius.circular(62.0),),
  115. labelStyle: TextStyle(
  116. color: Colors.white, fontSize: 20.0)),
  117. controller: descricaoController,
  118. ),
  119. ),
  120. Padding(
  121. padding: EdgeInsets.only(top: 10.0),
  122. child: Container(
  123. child: FlatButton(
  124. color: Colors.orange,
  125. textColor: Colors.white,
  126. disabledColor: Colors.grey,
  127. disabledTextColor: Colors.black,
  128. padding: EdgeInsets.all(8.0),
  129. splashColor: Colors.orangeAccent,
  130. onPressed: _relatorio,
  131. shape: RoundedRectangleBorder(borderRadius: new BorderRadius.circular(40.0)),
  132. child: Text(
  133. "Enviar pedido",
  134. style: TextStyle(fontSize: 20.0),
  135. ),
  136. ),
  137. ),
  138. ),
  139. Text(
  140. _infoText,
  141. textAlign: TextAlign.end,
  142. style: TextStyle(color: Colors.white, fontSize: 20.0),
  143. ),
  144. ],
  145. )),
  146. ),
  147. ],
  148. ));
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement