diff --git a/examples/material_gallery/lib/demo/page_selector_demo.dart b/examples/material_gallery/lib/demo/page_selector_demo.dart index 9bfc9f2139..53dd53e4ad 100644 --- a/examples/material_gallery/lib/demo/page_selector_demo.dart +++ b/examples/material_gallery/lib/demo/page_selector_demo.dart @@ -85,9 +85,8 @@ class TabViewDemo extends StatelessComponent { ) ), new Flexible( - child: new TabBarView( - items: _iconNames, - itemBuilder: _buildTabView + child: new TabBarView( + children: _iconNames.map(_buildTabView).toList() ) ) ]); diff --git a/examples/material_gallery/lib/demo/tabs_demo.dart b/examples/material_gallery/lib/demo/tabs_demo.dart index 7e4235391c..1ba113aac6 100644 --- a/examples/material_gallery/lib/demo/tabs_demo.dart +++ b/examples/material_gallery/lib/demo/tabs_demo.dart @@ -27,9 +27,8 @@ class TabsDemo extends StatefulComponent { class _TabsDemoState extends State { Widget build(_) { - return new TabBarView( - items: _iconNames, - itemBuilder: (String iconName) { + return new TabBarView( + children: _iconNames.map((String iconName) { return new Container( key: new ValueKey(iconName), padding: const EdgeDims.all(12.0), @@ -37,7 +36,7 @@ class _TabsDemoState extends State { child: new Center(child: new Icon(icon: "action/$iconName", size:IconSize.s48)) ) ); - } + }).toList() ); } } diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index f602551770..37c00e21af 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -267,18 +267,11 @@ class StockHomeState extends State { toolBar: _isSearching ? buildSearchBar() : buildToolBar(), floatingActionButton: buildFloatingActionButton(), drawer: _buildDrawer(context), - body: new TabBarView( - items: [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: [ + _buildStockTab(context, StockHomeTab.market, config.symbols), + _buildStockTab(context, StockHomeTab.portfolio, portfolioSymbols), + ] ) ) ); diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index aea6c53f17..7420938f2d 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -764,36 +764,29 @@ class _TabBarState extends ScrollableState> implements TabBarSelect } } -typedef Widget TabItemBuilder(T item); - -class TabBarView extends PageableList { +class TabBarView extends PageableList { TabBarView({ Key key, - List items, - TabItemBuilder itemBuilder - }) : items = items, itemBuilder = itemBuilder, super( + List children + }) : super( key: key, scrollDirection: ScrollDirection.horizontal, - children: items.map((T item) => itemBuilder(item)).toList(), - itemsWrap: false + children: children ) { - assert(items != null); - assert(items.length > 1); + assert(children != null); + assert(children.length > 1); } - final List items; - final TabItemBuilder itemBuilder; - - _TabBarViewState createState() => new _TabBarViewState(); + _TabBarViewState createState() => new _TabBarViewState(); } -class _TabBarViewState extends PageableListState> implements TabBarSelectionPerformanceListener { +class _TabBarViewState extends PageableListState implements TabBarSelectionPerformanceListener { TabBarSelectionState _selection; List _items; AnimationDirection _scrollDirection = AnimationDirection.forward; - int get _tabCount => config.items.length; + int get _tabCount => config.children.length; BoundedBehavior _boundedBehavior; @@ -802,7 +795,7 @@ class _TabBarViewState extends PageableListState> implements Ta return _boundedBehavior; } - void _initSelection(TabBarSelectionState selection) { + void _initSelection(TabBarSelectionState selection) { _selection = selection; if (_selection != null) { _selection.registerPerformanceListener(this); @@ -919,7 +912,7 @@ class _TabBarViewState extends PageableListState> implements Ta } Widget buildContent(BuildContext context) { - TabBarSelectionState newSelection = TabBarSelection.of(context); + TabBarSelectionState newSelection = TabBarSelection.of(context); if (_selection != newSelection) _initSelection(newSelection); return new PageViewport( diff --git a/packages/flutter/lib/src/widgets/scrollable_list.dart b/packages/flutter/lib/src/widgets/scrollable_list.dart index a9d5f2f314..2c113baf1b 100644 --- a/packages/flutter/lib/src/widgets/scrollable_list.dart +++ b/packages/flutter/lib/src/widgets/scrollable_list.dart @@ -41,10 +41,10 @@ class ScrollableList extends Scrollable { final ScrollableListPainter scrollableListPainter; final Iterable children; - ScrollableState createState() => new _ScrollableList2State(); + ScrollableState createState() => new _ScrollableListState(); } -class _ScrollableList2State extends ScrollableState { +class _ScrollableListState extends ScrollableState { ScrollBehavior createScrollBehavior() => new OverscrollBehavior(); ExtentScrollBehavior get scrollBehavior => super.scrollBehavior;