Last active
March 13, 2018 19:47
-
-
Save Blasanka/b8bf670afe693fadf5753f90f44a64b2 to your computer and use it in GitHub Desktop.
This is a simple code snippet to use to explain how you can change text status as soon as a button is pressed in Flutter SDK and Dart. You can refer https://slcoderlk.blogspot.com/2018/03/how-to-change-text-status-as-soon-as.html to see whats happening in this code.
This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| void main() => runApp(new MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return new MaterialApp( | |
| title: 'Converter App', | |
| theme: new ThemeData( | |
| primarySwatch: Colors.blue, | |
| ), | |
| home: new Scaffold( | |
| appBar: new AppBar( | |
| title: new Text('Converter App'), | |
| ), | |
| body: new Center( | |
| child: new Converter(), | |
| ), | |
| ) | |
| ); | |
| } | |
| } | |
| class Converter extends StatefulWidget { | |
| @override | |
| _ConverterWidget createState() => new _ConverterWidget(); | |
| } | |
| class _ConverterWidget extends State<Converter> { | |
| String value = "click Me"; | |
| @override | |
| Widget build(BuildContext context) { | |
| return new Column( | |
| children: <Widget>[ | |
| new Text(value), | |
| new RaisedButton( | |
| child: new Text('Click me'), | |
| onPressed: () { | |
| setState(() { | |
| value += ' Me'; | |
| }); | |
| }, | |
| ), | |
| ], | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment