Created
July 10, 2017 22:51
-
-
Save collinjackson/f004c316cca2f6c6bee70ed491b85f2a 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
import 'package:flutter/material.dart'; | |
class MyHomePage extends StatefulWidget { | |
MyHomePageState createState() => new MyHomePageState(); | |
} | |
class MyHomePageState extends State<MyHomePage> { | |
TextEditingController _controller = new TextEditingController(); | |
String _title = ""; | |
@override | |
void initState() { | |
_controller.addListener(() { | |
setState(() { | |
_title = _controller.value.text; | |
print("Title value: $_title ${_title.length}"); | |
}); | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar( | |
title: new Text(_title), | |
), | |
body: new Container( | |
alignment: FractionalOffset.center, | |
padding: new EdgeInsets.all(20.0), | |
child: new TextFormField( | |
controller: _controller, | |
), | |
), | |
); | |
} | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
home: new MyHomePage(), | |
); | |
} | |
} | |
void main() { | |
runApp(new MyApp()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment