Simplify TabView API
Instead of taking a builder and a generic type, we can just take a List<Widget>.
This commit is contained in:
@@ -85,9 +85,8 @@ class TabViewDemo extends StatelessComponent {
|
||||
)
|
||||
),
|
||||
new Flexible(
|
||||
child: new TabBarView<String>(
|
||||
items: _iconNames,
|
||||
itemBuilder: _buildTabView
|
||||
child: new TabBarView(
|
||||
children: _iconNames.map(_buildTabView).toList()
|
||||
)
|
||||
)
|
||||
]);
|
||||
|
||||
@@ -27,9 +27,8 @@ class TabsDemo extends StatefulComponent {
|
||||
|
||||
class _TabsDemoState extends State<TabsDemo> {
|
||||
Widget build(_) {
|
||||
return new TabBarView<String>(
|
||||
items: _iconNames,
|
||||
itemBuilder: (String iconName) {
|
||||
return new TabBarView(
|
||||
children: _iconNames.map((String iconName) {
|
||||
return new Container(
|
||||
key: new ValueKey<String>(iconName),
|
||||
padding: const EdgeDims.all(12.0),
|
||||
@@ -37,7 +36,7 @@ class _TabsDemoState extends State<TabsDemo> {
|
||||
child: new Center(child: new Icon(icon: "action/$iconName", size:IconSize.s48))
|
||||
)
|
||||
);
|
||||
}
|
||||
}).toList()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,18 +267,11 @@ class StockHomeState extends State<StockHome> {
|
||||
toolBar: _isSearching ? buildSearchBar() : buildToolBar(),
|
||||
floatingActionButton: buildFloatingActionButton(),
|
||||
drawer: _buildDrawer(context),
|
||||
body: new TabBarView<StockHomeTab>(
|
||||
items: <StockHomeTab>[StockHomeTab.market, StockHomeTab.portfolio],
|
||||
itemBuilder: (StockHomeTab tab) {
|
||||
switch (tab) {
|
||||
case StockHomeTab.market:
|
||||
return _buildStockTab(context, tab, config.symbols);
|
||||
case StockHomeTab.portfolio:
|
||||
return _buildStockTab(context, tab, portfolioSymbols);
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
body: new TabBarView(
|
||||
children: <Widget>[
|
||||
_buildStockTab(context, StockHomeTab.market, config.symbols),
|
||||
_buildStockTab(context, StockHomeTab.portfolio, portfolioSymbols),
|
||||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user