From b672a3d4361b777bd21f2f2c6b65a12807186c61 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Sun, 14 Feb 2016 14:22:23 -0800 Subject: [PATCH] Stocks input field for company name doesn't work We weren't listening to the onChange handler. Fixes #1850 --- examples/stocks/lib/stock_home.dart | 40 +++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 3692bffed3..e90edb3486 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -262,18 +262,8 @@ class StockHomeState extends State { void _handleCreateCompany() { showModalBottomSheet( - // TODO(ianh): Fill this out. context: context, - builder: (BuildContext context) { - return new Column( - children: [ - new Input( - autofocus: true, - hintText: 'Company Name' - ), - ] - ); - } + builder: (BuildContext context) => new _CreateCompanySheet() ); } @@ -303,3 +293,31 @@ class StockHomeState extends State { ); } } + +class _CreateCompanySheet extends StatefulComponent { + _CreateCompanySheetState createState() => new _CreateCompanySheetState(); +} + +class _CreateCompanySheetState extends State<_CreateCompanySheet> { + InputValue _companyName = InputValue.empty; + + void _handleCompanyNameChanged(InputValue value) { + setState(() { + _companyName = value; + }); + } + + Widget build(BuildContext context) { + // TODO(ianh): Fill this out. + return new Column( + children: [ + new Input( + autofocus: true, + hintText: 'Company Name', + value: _companyName, + onChanged: _handleCompanyNameChanged + ), + ] + ); + } +}