Created
March 31, 2017 16:36
-
-
Save alardizabal/d6ddf369f3a3350ea0666c0c4290cc2e to your computer and use it in GitHub Desktop.
Flutter Input Widget Demo
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'; | |
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> { | |
InputValue _currentInput; | |
@override | |
void initState() { | |
super.initState(); | |
_currentInput = const InputValue(); | |
} | |
void _handleInputChange(InputValue input) { | |
setState(() { | |
_currentInput = input; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new Column( | |
children: [ | |
new Text(_currentInput.text), | |
new Material( | |
child: new Container( | |
height: 64.0, | |
color: new Color(0xFFADD8E6), | |
child: new Input( | |
onChanged: _handleInputChange, | |
value: _currentInput, | |
), | |
), | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is for flutter/flutter#8775, which I believe @cbracken is taking.