diff --git a/example/lib/main.dart b/example/lib/main.dart index 4f016f41..7edcafba 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,7 +17,6 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatelessWidget { - @override Widget build(BuildContext context) { return DefaultTabController( @@ -25,22 +24,20 @@ class MyHomePage extends StatelessWidget { child: Scaffold( appBar: AppBar( title: TabBar( - tabs: [ - Tab( - text: 'Example 1: Navigation', - ), - Tab( - text: 'Example 2: Form' - ) - ] + tabs: [ + Tab( + text: 'Example 1: Navigation', + ), + Tab(text: 'Example 2: Form') + ], ), ), body: TabBarView( children: [ NavigationExample(), - FormExample() - ] - ) + FormExample(), + ], + ), ), ); } @@ -52,17 +49,17 @@ class NavigationExample extends StatelessWidget { return Padding( padding: EdgeInsets.all(32.0), child: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox(height: 10.0,), TypeAheadField( textFieldConfiguration: TextFieldConfiguration( autofocus: true, - style: DefaultTextStyle.of(context).style.copyWith( - fontStyle: FontStyle.italic - ), + style: DefaultTextStyle.of(context) + .style + .copyWith(fontStyle: FontStyle.italic), decoration: InputDecoration( border: OutlineInputBorder(), - hintText: 'What are you looking for?' + hintText: 'What are you looking for?', ), ), suggestionsCallback: (pattern) async { @@ -76,9 +73,11 @@ class NavigationExample extends StatelessWidget { ); }, onSuggestionSelected: (suggestion) { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => ProductPage(product: suggestion) - )); + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => ProductPage(product: suggestion), + ), + ); }, ), ], @@ -93,7 +92,6 @@ class FormExample extends StatefulWidget { } class _FormExampleState extends State { - final GlobalKey _formKey = GlobalKey(); final TextEditingController _typeAheadController = TextEditingController(); @@ -107,14 +105,10 @@ class _FormExampleState extends State { padding: EdgeInsets.all(32.0), child: Column( children: [ - Text( - 'What is your favorite city?' - ), + Text('What is your favorite city?'), TypeAheadFormField( textFieldConfiguration: TextFieldConfiguration( - decoration: InputDecoration( - labelText: 'City' - ), + decoration: InputDecoration(labelText: 'City'), controller: this._typeAheadController, ), suggestionsCallback: (pattern) { @@ -138,15 +132,17 @@ class _FormExampleState extends State { }, onSaved: (value) => this._selectedCity = value, ), - SizedBox(height: 10.0,), + SizedBox( + height: 10.0, + ), RaisedButton( child: Text('Submit'), onPressed: () { if (this._formKey.currentState.validate()) { this._formKey.currentState.save(); Scaffold.of(context).showSnackBar(SnackBar( - content: Text('Your Favorite City is ${this._selectedCity}') - )); + content: + Text('Your Favorite City is ${this._selectedCity}'))); } }, ) @@ -157,9 +153,7 @@ class _FormExampleState extends State { } } - class ProductPage extends StatelessWidget { - final Map product; ProductPage({this.product}); @@ -186,22 +180,17 @@ class ProductPage extends StatelessWidget { } } - class BackendService { static Future getSuggestions(String query) async { await Future.delayed(Duration(seconds: 1)); return List.generate(3, (index) { - return { - 'name': query + index.toString(), - 'price': Random().nextInt(100) - }; + return {'name': query + index.toString(), 'price': Random().nextInt(100)}; }); } } class CitiesService { - static final cities = [ 'Beirut', 'Damascus', @@ -219,7 +208,8 @@ class CitiesService { final cities = CitiesService.cities; cities.sort((a, b) { - return CitiesService._distance(query, a) - CitiesService._distance(query, b); + return CitiesService._distance(query, a) - + CitiesService._distance(query, b); }); return cities.take(4).toList();