Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() {
- runApp(MaterialApp(
- home: MyButton(),
- ));
- }
- class MyButton extends StatefulWidget {
- @override
- MyButtonState createState() => MyButtonState();
- }
- class MyButtonState extends State<MyButton> {
- int counter = 0;
- List<String> strings = ['Odio', 'mi', 'computadora', "lenta","!!!"];
- String displayedString = "Haciendo Tarea";
- void onPressOfButton() {
- setState(() {
- displayedString = strings[counter];
- counter = counter < 4 ? counter + 1 : 0;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text("Stateful Widget"),
- backgroundColor: Colors.blue,
- ),
- body: Container(
- child: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Text(displayedString, style: TextStyle(fontSize: 40.0)),
- Padding(padding: EdgeInsets.all(10.0)),
- RaisedButton(
- child: Text(
- "Press me",
- style: TextStyle(color: Colors.white),
- ),
- color: Colors.black,
- onPressed: onPressOfButton,
- )
- ],
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement