Skip to content

Instantly share code, notes, and snippets.

@collinjackson
Created July 10, 2017 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collinjackson/f004c316cca2f6c6bee70ed491b85f2a to your computer and use it in GitHub Desktop.
Save collinjackson/f004c316cca2f6c6bee70ed491b85f2a to your computer and use it in GitHub Desktop.
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