Skip to content

Instantly share code, notes, and snippets.

@xster
Created April 20, 2017 23:29
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 xster/510bcc738b14fc4ae97758abcf361f7d to your computer and use it in GitHub Desktop.
Save xster/510bcc738b14fc4ae97758abcf361f7d to your computer and use it in GitHub Desktop.
TextField performance
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Input Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Input Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
TextEditingController _textController =
new TextEditingController(text: 'Initial text');
@override
Widget build(BuildContext context) {
return new Column(
children: [
new Text(
_textController.text,
softWrap: true,
),
new Material(
child: new Container(
height: 64.0,
color: new Color(0xFFADD8E6),
child: new TextField(
controller: _textController,
maxLines: 5,
),
),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment