Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3.  
  4.  
  5. void main() {
  6.  
  7. runApp(MaterialApp(
  8.  
  9. home: MyButton(),
  10.  
  11. ));
  12.  
  13. }
  14.  
  15.  
  16.  
  17. class MyButton extends StatefulWidget {
  18.  
  19. @override
  20.  
  21. MyButtonState createState() => MyButtonState();
  22.  
  23. }
  24.  
  25.  
  26.  
  27. class MyButtonState extends State<MyButton> {
  28.  
  29. int counter = 0;
  30.  
  31. List<String> strings = ['Hoy', 'luces', 'tan', "increiblemente","hermasa(o)!"];
  32.  
  33. String displayedString = "BIENVENIDO!";
  34.  
  35.  
  36.  
  37. void onPressOfButton() {
  38.  
  39. setState(() {
  40.  
  41. displayedString = strings[counter];
  42.  
  43. counter = counter < 4 ? counter + 1 : 0;
  44.  
  45. });
  46.  
  47. }
  48.  
  49.  
  50.  
  51. @override
  52.  
  53. Widget build(BuildContext context) {
  54.  
  55. return Scaffold(
  56.  
  57. appBar: AppBar(
  58.  
  59. title: Text("inicio"),
  60.  
  61. backgroundColor: Colors.pink,
  62.  
  63. ),
  64.  
  65. body: Container(
  66.  
  67. child: Center(
  68.  
  69. child: Column(
  70.  
  71. mainAxisAlignment: MainAxisAlignment.center,
  72.  
  73. children: <Widget>[
  74.  
  75. Text(displayedString, style: TextStyle(fontSize: 40.0)),
  76.  
  77. Padding(padding: EdgeInsets.all(10.0)),
  78.  
  79. RaisedButton(
  80.  
  81. child: Text(
  82.  
  83. "Press me",
  84.  
  85. style: TextStyle(color: Colors.black87),
  86.  
  87. ),
  88.  
  89. color: Colors.pinkAccent,
  90.  
  91. onPressed: onPressOfButton,
  92.  
  93. )
  94.  
  95. ],
  96.  
  97. ),
  98.  
  99. ),
  100.  
  101. ),
  102.  
  103. );
  104.  
  105. }
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement