SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4.   runApp(MaterialApp(
  5.     home: MyButton(),
  6.   ));
  7. }
  8.  
  9. class MyButton extends StatefulWidget {
  10.   @override
  11.   MyButtonState createState() => MyButtonState();
  12. }
  13.  
  14. class MyButtonState extends State<MyButton> {
  15.   int counter = 0;
  16.   List<String> strings = ['Odio', 'mi', 'computadora', "lenta","!!!"];
  17.   String displayedString = "Haciendo Tarea";
  18.  
  19.   void onPressOfButton() {
  20.     setState(() {
  21.       displayedString = strings[counter];
  22.       counter = counter < 4 ? counter + 1 : 0;
  23.     });
  24.   }
  25.  
  26.   @override
  27.   Widget build(BuildContext context) {
  28.     return Scaffold(
  29.       appBar: AppBar(
  30.         title: Text("Stateful Widget"),
  31.         backgroundColor: Colors.blue,
  32.       ),
  33.       body: Container(
  34.         child: Center(
  35.           child: Column(
  36.             mainAxisAlignment: MainAxisAlignment.center,
  37.             children: <Widget>[
  38.               Text(displayedString, style: TextStyle(fontSize: 40.0)),
  39.               Padding(padding: EdgeInsets.all(10.0)),
  40.               RaisedButton(
  41.                 child: Text(
  42.                   "Press me",
  43.                   style: TextStyle(color: Colors.white),
  44.                 ),
  45.                 color: Colors.black,
  46.                 onPressed: onPressOfButton,
  47.               )
  48.             ],
  49.           ),
  50.         ),
  51.       ),
  52.     );
  53.   }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top