Created
February 10, 2020 15:08
-
-
Save Dviejopomata/d4ad12b5be93044b56189dcf711f483d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: ContadorWidget(), | |
); | |
} | |
} | |
class ContadorWidget extends StatefulWidget { | |
@override | |
_ContadorWidgetState createState() => _ContadorWidgetState(); | |
} | |
class _ContadorWidgetState extends State<ContadorWidget> { | |
int _contador = 0; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Kung Fu Academy"), | |
), | |
floatingActionButton: FloatingActionButton( | |
child: Icon(Icons.add), | |
onPressed: () { | |
print("Este botón ha sido pulsado"); | |
setState((){ | |
_contador++; | |
}); | |
}, | |
), | |
body: Center( | |
child: Column( | |
mainAxisSize: MainAxisSize.max, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text('Nuestra primera aplicacion Flutter'), | |
Text( | |
_contador.toString(), | |
style: Theme.of(context).textTheme.headline4, | |
), | |
Text('Hola que tal'), | |
], | |
) | |
) | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment