Skip to content

Instantly share code, notes, and snippets.

@collinjackson
Last active February 8, 2016 22:32
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/33906003d2eef047b6fc to your computer and use it in GitHub Desktop.
Save collinjackson/33906003d2eef047b6fc to your computer and use it in GitHub Desktop.
New Input API example
import 'package:flutter/material.dart';
void main() {
runApp(
new MaterialApp(
title: "Input Demo",
routes: <String, RouteBuilder>{
'/': (RouteArguments args) => new FlutterDemo()
}
)
);
}
class FlutterDemo extends StatefulComponent {
@override
State createState() => new FlutterDemoState();
}
class FlutterDemoState extends State {
GlobalKey _inputKey = new GlobalKey();
InputValue _inputValue = InputValue.empty;
Widget build(BuildContext context) {
return new Scaffold(
toolBar: new ToolBar(
center: new Text("Input Demo")
),
body: new Material(
child: new Center(
child: new Column(
children: <Widget>[
new Flexible(
child: new Container(
decoration: const BoxDecoration(
backgroundColor: const Color(0xFF00FF00)
)
)
),
new Input(
key: _inputKey,
value: _inputValue,
onChanged: (InputValue value) {
setState(() {
_inputValue = value;
});
},
onSubmitted: (InputValue value) {
print("Submitted ${value.text}");
setState(() {
_inputValue = InputValue.empty;
});
}
)
]
)
)
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment