diff --git a/lib/drop_down_widget.dart b/lib/drop_down_widget.dart index 78b293d..e8dcce8 100644 --- a/lib/drop_down_widget.dart +++ b/lib/drop_down_widget.dart @@ -1,38 +1,51 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'home_widget.dart'; -class DropDownWidget extends StatefulWidget { +class DropDownWidget extends StatefulWidget{ @override _DropDownWidget createState() => _DropDownWidget(); + } class _DropDownWidget extends State{ - String curSport = "Men's Basketball"; + Item selectedSport; + String curSport; + Color _appBarColor; + List colorList = [ + const Item("Men's Basketball", Colors.red), + const Item("Women's Basketball", Colors.pinkAccent), + const Item('Baseball', Colors.yellow), + ]; @override Widget build(BuildContext context) { - return DropdownButton( - value: curSport, + return DropdownButton( + value: selectedSport, icon: Icon(Icons.arrow_drop_down), iconSize: 24, style: TextStyle(color: Colors.black), iconEnabledColor: Colors.white, - onChanged: (String newSport) { + onChanged: (Item value) { setState(() { - curSport = newSport; + selectedSport = value; + curSport = selectedSport.name; + _appBarColor = selectedSport.color; }); }, - items: ["Men's Basketball", "Women's Basketball", "Baseball", "Softball", "FootBall"] - .map>((String value) { - return DropdownMenuItem( - value: value, + items: colorList.map>((Item item) { + return DropdownMenuItem( + value: item, child: SizedBox( width: 100, - child: Text(value), + child: Text(item.name), ), ); }).toList(), ); } + String getString(){ + return curSport; + } } \ No newline at end of file diff --git a/lib/home_widget.dart b/lib/home_widget.dart index cb41b75..f0e8ce4 100644 --- a/lib/home_widget.dart +++ b/lib/home_widget.dart @@ -19,16 +19,14 @@ class _HomeState extends State{ PlaceholderWidget(Colors.black38), ]; + DropDownWidget ddw = DropDownWidget(); + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - - //title: Text(appBarTitle), - actions: [ - DropDownWidget(), - ], - backgroundColor: Colors.green, + title: ddw, + //backgroundColor: , ), body: _children[_currentIndex], bottomNavigationBar: BottomNavigationBar( @@ -64,6 +62,13 @@ class _HomeState extends State{ void onTabTapped(int index) { setState(() { _currentIndex = index; + print(ddw); }); } +} + +class Item { + const Item(this.name, this.color); + final String name; + final Color color; } \ No newline at end of file