From 9df8b7211b8e9d6b91257d6b135ecfa42b20320b Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 13 Feb 2017 17:45:29 -0800 Subject: [PATCH] Deprecate old list-based scrolling widgets (#8120) - MaterialList - ScrollableList - ScrollableLazyList - LazyBlock All of these widgets can be replaced by ListView now. --- .../lib/demo/overscroll_demo.dart | 2 +- packages/flutter/lib/src/material/list.dart | 2 +- .../lib/src/material/refresh_indicator.dart | 5 ----- .../flutter/lib/src/material/two_level_list.dart | 2 +- packages/flutter/lib/src/widgets/lazy_block.dart | 16 +++++++++++++--- .../flutter/lib/src/widgets/scrollable_list.dart | 4 ++++ packages/flutter/test/material/list_test.dart | 12 ------------ 7 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 packages/flutter/test/material/list_test.dart diff --git a/examples/flutter_gallery/lib/demo/overscroll_demo.dart b/examples/flutter_gallery/lib/demo/overscroll_demo.dart index 71b537a2ed..b77e7460b7 100644 --- a/examples/flutter_gallery/lib/demo/overscroll_demo.dart +++ b/examples/flutter_gallery/lib/demo/overscroll_demo.dart @@ -45,7 +45,7 @@ class OverscrollDemoState extends State { @override Widget build(BuildContext context) { - Widget body = new MaterialList( + Widget body = new MaterialList( // ignore: DEPRECATED_MEMBER_USE type: MaterialListType.threeLine, padding: const EdgeInsets.all(8.0), scrollableKey: _scrollableKey, diff --git a/packages/flutter/lib/src/material/list.dart b/packages/flutter/lib/src/material/list.dart index 68a8e1ba03..290ed0f7e3 100644 --- a/packages/flutter/lib/src/material/list.dart +++ b/packages/flutter/lib/src/material/list.dart @@ -8,7 +8,6 @@ import 'package:flutter/widgets.dart'; /// /// See also: /// -/// * [MaterialList] /// * [ListItem] /// * [kListItemExtent] /// * @@ -57,6 +56,7 @@ Map kListItemExtent = const /// expand. /// * [GridView] /// * +@Deprecated('use ListView instead') class MaterialList extends StatelessWidget { /// Creates a material list. /// diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index 0e3de4877f..28e326a559 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -71,11 +71,6 @@ enum _DismissTransition { /// it returns. The refresh indicator disappears after the callback's /// Future has completed. /// -/// The required [scrollableKey] parameter identifies the scrollable widget -/// whose scrollOffset is monitored by this RefreshIndicator. The same -/// scrollableKey must also be set on the scrollable. See [Block.scrollableKey], -/// [ScrollableList.scrollableKey], etc. -/// /// See also: /// /// * diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index f02e13a364..dae184cdc4 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -256,7 +256,7 @@ class _TwoLevelSublistState extends State with SingleTickerProv /// /// * [TwoLevelSublist] /// * [TwoLevelListItem] -/// * [MaterialList], for lists that only have one level. +/// * [ListView], for lists that only have one level. class TwoLevelList extends StatelessWidget { /// Creates a scrollable list of items that can expand and collapse. /// diff --git a/packages/flutter/lib/src/widgets/lazy_block.dart b/packages/flutter/lib/src/widgets/lazy_block.dart index 255966958b..d0acf022bf 100644 --- a/packages/flutter/lib/src/widgets/lazy_block.dart +++ b/packages/flutter/lib/src/widgets/lazy_block.dart @@ -22,6 +22,7 @@ import 'scroll_behavior.dart'; /// /// See also [LazyBlockBuilder] for an implementation of LazyBlockDelegate based /// on an [IndexedWidgetBuilder] closure. +@Deprecated('use SliverChildDelegate instead') abstract class LazyBlockDelegate { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. @@ -86,9 +87,10 @@ abstract class LazyBlockDelegate { double estimateTotalExtent(int firstIndex, int lastIndex, double minOffset, double firstStartOffset, double lastEndOffset); } -/// Signature for callbacks that estimate the total height of a [LazyBlock]'s contents. +/// Signature for callbacks that estimate the total height of a `LazyBlock`'s contents. /// -/// See [LazyBlockDelegate.estimateTotalExtent] for details. +/// See `LazyBlockDelegate.estimateTotalExtent` for details. +@deprecated typedef double TotalExtentEstimator(int firstIndex, int lastIndex, double minOffset, double firstStartOffset, double lastEndOffset); /// Uses an [IndexedWidgetBuilder] to provide children for [LazyBlock]. @@ -100,6 +102,7 @@ typedef double TotalExtentEstimator(int firstIndex, int lastIndex, double minOff /// [estimateTotalExtent] callback. /// /// See also [LazyBlockViewport]. +@Deprecated('use SliverChildBuilderDelegate instead') class LazyBlockBuilder extends LazyBlockDelegate { /// Creates a LazyBlockBuilder based on the given builder. LazyBlockBuilder({ this.builder, this.totalExtentEstimator }) { @@ -143,6 +146,7 @@ class LazyBlockBuilder extends LazyBlockDelegate { /// Uses a [List] to provide children for [LazyBlock]. /// /// See also [LazyBlockViewport]. +@Deprecated('use SliverChildListDelegate instead') class LazyBlockChildren extends LazyBlockDelegate { /// Creates a LazyBlockChildren that displays the given children. /// @@ -202,6 +206,7 @@ class LazyBlockChildren extends LazyBlockDelegate { /// Consider [Block] if you have a small number of children that will only /// scroll in unusual circumstances (e.g. when the user's device is smaller than /// expected). +@Deprecated('use ListView instead') class LazyBlock extends StatelessWidget { /// Creates an infinite scrolling list of variable height children. /// @@ -301,7 +306,7 @@ class LazyBlock extends StatelessWidget { } } -/// Signature used by [LazyBlockViewport] to report its interior and exterior dimensions. +/// Signature used by `LazyBlockViewport` to report its interior and exterior dimensions. /// /// * The `firstIndex` is the index of the child that is visible at the /// starting edge of the viewport. @@ -323,6 +328,7 @@ class LazyBlock extends StatelessWidget { /// * The `containerExtent` is the exterior dimension of the viewport (i.e., /// the amount of the thing inside the viewport that is visible from outside /// the viewport). +@deprecated typedef void LazyBlockExtentsChangedCallback(int firstIndex, int lastIndex, double firstStartOffset, double lastEndOffset, double minScrollOffset, double containerExtent); /// A viewport on an infinite list of variable height children. @@ -346,6 +352,7 @@ typedef void LazyBlockExtentsChangedCallback(int firstIndex, int lastIndex, doub /// is only one child. /// /// For a scrollable version of this widget, see [LazyBlock]. +@deprecated class LazyBlockViewport extends RenderObjectWidget { /// Creates a viewport on an infinite list of variable height children. /// @@ -395,8 +402,10 @@ class LazyBlockViewport extends RenderObjectWidget { _RenderLazyBlock createRenderObject(BuildContext context) => new _RenderLazyBlock(); } +@deprecated class _LazyBlockParentData extends ContainerBoxParentDataMixin { } +@deprecated class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> { _RenderLazyBlock({ Offset paintOffset: Offset.zero, @@ -471,6 +480,7 @@ class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> { } } +@deprecated class _LazyBlockElement extends RenderObjectElement { _LazyBlockElement(LazyBlockViewport widget) : super(widget); diff --git a/packages/flutter/lib/src/widgets/scrollable_list.dart b/packages/flutter/lib/src/widgets/scrollable_list.dart index df99b9478f..f6529e30d7 100644 --- a/packages/flutter/lib/src/widgets/scrollable_list.dart +++ b/packages/flutter/lib/src/widgets/scrollable_list.dart @@ -35,6 +35,7 @@ import 'virtual_viewport.dart'; /// * [ScrollableLazyList], a more efficient version of [ScrollableList]. /// * [LazyBlock], a more efficient version of [Block]. /// * [ScrollableViewport], which only has one child. +@Deprecated('use ListView instead') class ScrollableList extends StatelessWidget { /// Creats a scrollable list of children that have equal size. /// @@ -381,6 +382,7 @@ class _VirtualListViewportElement extends VirtualViewportElement { /// * [LazyListViewport]. /// * [LazyBlockViewport]. /// * [GridViewport]. +@deprecated class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable { /// Creates a virtual viewport onto a list of equally sized children. /// @@ -423,6 +425,7 @@ class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable /// /// * [ScrollableList]. /// * [LazyBlock]. +@Deprecated('use ListView.builder instead') class ScrollableLazyList extends StatelessWidget { /// Creates an infinite scrollable list of children that have equal size. /// @@ -578,6 +581,7 @@ class ScrollableLazyList extends StatelessWidget { /// /// * [ListViewport]. /// * [LazyBlockViewport]. +@deprecated class LazyListViewport extends _VirtualListViewport with VirtualViewportFromBuilder { /// Creates a virtual viewport onto an extremely large or infinite list of equally sized children. /// diff --git a/packages/flutter/test/material/list_test.dart b/packages/flutter/test/material/list_test.dart deleted file mode 100644 index d86e7c60ff..0000000000 --- a/packages/flutter/test/material/list_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - testWidgets('MaterialList default control', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new MaterialList())); - }); -}