Commit 9df8b721 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Deprecate old list-based scrolling widgets (#8120)

- MaterialList
 - ScrollableList
 - ScrollableLazyList
 - LazyBlock

All of these widgets can be replaced by ListView now.
parent c6757570
...@@ -45,7 +45,7 @@ class OverscrollDemoState extends State<OverscrollDemo> { ...@@ -45,7 +45,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget body = new MaterialList( Widget body = new MaterialList( // ignore: DEPRECATED_MEMBER_USE
type: MaterialListType.threeLine, type: MaterialListType.threeLine,
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
scrollableKey: _scrollableKey, scrollableKey: _scrollableKey,
......
...@@ -8,7 +8,6 @@ import 'package:flutter/widgets.dart'; ...@@ -8,7 +8,6 @@ import 'package:flutter/widgets.dart';
/// ///
/// See also: /// See also:
/// ///
/// * [MaterialList]
/// * [ListItem] /// * [ListItem]
/// * [kListItemExtent] /// * [kListItemExtent]
/// * <https://material.google.com/components/lists.html#lists-specs> /// * <https://material.google.com/components/lists.html#lists-specs>
...@@ -57,6 +56,7 @@ Map<MaterialListType, double> kListItemExtent = const <MaterialListType, double> ...@@ -57,6 +56,7 @@ Map<MaterialListType, double> kListItemExtent = const <MaterialListType, double>
/// expand. /// expand.
/// * [GridView] /// * [GridView]
/// * <https://material.google.com/components/lists.html> /// * <https://material.google.com/components/lists.html>
@Deprecated('use ListView instead')
class MaterialList extends StatelessWidget { class MaterialList extends StatelessWidget {
/// Creates a material list. /// Creates a material list.
/// ///
......
...@@ -71,11 +71,6 @@ enum _DismissTransition { ...@@ -71,11 +71,6 @@ enum _DismissTransition {
/// it returns. The refresh indicator disappears after the callback's /// it returns. The refresh indicator disappears after the callback's
/// Future has completed. /// 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: /// See also:
/// ///
/// * <https://material.google.com/patterns/swipe-to-refresh.html> /// * <https://material.google.com/patterns/swipe-to-refresh.html>
......
...@@ -256,7 +256,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> with SingleTickerProv ...@@ -256,7 +256,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> with SingleTickerProv
/// ///
/// * [TwoLevelSublist] /// * [TwoLevelSublist]
/// * [TwoLevelListItem] /// * [TwoLevelListItem]
/// * [MaterialList], for lists that only have one level. /// * [ListView], for lists that only have one level.
class TwoLevelList extends StatelessWidget { class TwoLevelList extends StatelessWidget {
/// Creates a scrollable list of items that can expand and collapse. /// Creates a scrollable list of items that can expand and collapse.
/// ///
......
...@@ -22,6 +22,7 @@ import 'scroll_behavior.dart'; ...@@ -22,6 +22,7 @@ import 'scroll_behavior.dart';
/// ///
/// See also [LazyBlockBuilder] for an implementation of LazyBlockDelegate based /// See also [LazyBlockBuilder] for an implementation of LazyBlockDelegate based
/// on an [IndexedWidgetBuilder] closure. /// on an [IndexedWidgetBuilder] closure.
@Deprecated('use SliverChildDelegate instead')
abstract class LazyBlockDelegate { abstract class LazyBlockDelegate {
/// Abstract const constructor. This constructor enables subclasses to provide /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions. /// const constructors so that they can be used in const expressions.
...@@ -86,9 +87,10 @@ abstract class LazyBlockDelegate { ...@@ -86,9 +87,10 @@ abstract class LazyBlockDelegate {
double estimateTotalExtent(int firstIndex, int lastIndex, double minOffset, double firstStartOffset, double lastEndOffset); 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); typedef double TotalExtentEstimator(int firstIndex, int lastIndex, double minOffset, double firstStartOffset, double lastEndOffset);
/// Uses an [IndexedWidgetBuilder] to provide children for [LazyBlock]. /// Uses an [IndexedWidgetBuilder] to provide children for [LazyBlock].
...@@ -100,6 +102,7 @@ typedef double TotalExtentEstimator(int firstIndex, int lastIndex, double minOff ...@@ -100,6 +102,7 @@ typedef double TotalExtentEstimator(int firstIndex, int lastIndex, double minOff
/// [estimateTotalExtent] callback. /// [estimateTotalExtent] callback.
/// ///
/// See also [LazyBlockViewport]. /// See also [LazyBlockViewport].
@Deprecated('use SliverChildBuilderDelegate instead')
class LazyBlockBuilder extends LazyBlockDelegate { class LazyBlockBuilder extends LazyBlockDelegate {
/// Creates a LazyBlockBuilder based on the given builder. /// Creates a LazyBlockBuilder based on the given builder.
LazyBlockBuilder({ this.builder, this.totalExtentEstimator }) { LazyBlockBuilder({ this.builder, this.totalExtentEstimator }) {
...@@ -143,6 +146,7 @@ class LazyBlockBuilder extends LazyBlockDelegate { ...@@ -143,6 +146,7 @@ class LazyBlockBuilder extends LazyBlockDelegate {
/// Uses a [List<Widget>] to provide children for [LazyBlock]. /// Uses a [List<Widget>] to provide children for [LazyBlock].
/// ///
/// See also [LazyBlockViewport]. /// See also [LazyBlockViewport].
@Deprecated('use SliverChildListDelegate instead')
class LazyBlockChildren extends LazyBlockDelegate { class LazyBlockChildren extends LazyBlockDelegate {
/// Creates a LazyBlockChildren that displays the given children. /// Creates a LazyBlockChildren that displays the given children.
/// ///
...@@ -202,6 +206,7 @@ class LazyBlockChildren extends LazyBlockDelegate { ...@@ -202,6 +206,7 @@ class LazyBlockChildren extends LazyBlockDelegate {
/// Consider [Block] if you have a small number of children that will only /// 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 /// scroll in unusual circumstances (e.g. when the user's device is smaller than
/// expected). /// expected).
@Deprecated('use ListView instead')
class LazyBlock extends StatelessWidget { class LazyBlock extends StatelessWidget {
/// Creates an infinite scrolling list of variable height children. /// Creates an infinite scrolling list of variable height children.
/// ///
...@@ -301,7 +306,7 @@ class LazyBlock extends StatelessWidget { ...@@ -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 /// * The `firstIndex` is the index of the child that is visible at the
/// starting edge of the viewport. /// starting edge of the viewport.
...@@ -323,6 +328,7 @@ class LazyBlock extends StatelessWidget { ...@@ -323,6 +328,7 @@ class LazyBlock extends StatelessWidget {
/// * The `containerExtent` is the exterior dimension of the viewport (i.e., /// * 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 amount of the thing inside the viewport that is visible from outside
/// the viewport). /// the viewport).
@deprecated
typedef void LazyBlockExtentsChangedCallback(int firstIndex, int lastIndex, double firstStartOffset, double lastEndOffset, double minScrollOffset, double containerExtent); 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. /// A viewport on an infinite list of variable height children.
...@@ -346,6 +352,7 @@ typedef void LazyBlockExtentsChangedCallback(int firstIndex, int lastIndex, doub ...@@ -346,6 +352,7 @@ typedef void LazyBlockExtentsChangedCallback(int firstIndex, int lastIndex, doub
/// is only one child. /// is only one child.
/// ///
/// For a scrollable version of this widget, see [LazyBlock]. /// For a scrollable version of this widget, see [LazyBlock].
@deprecated
class LazyBlockViewport extends RenderObjectWidget { class LazyBlockViewport extends RenderObjectWidget {
/// Creates a viewport on an infinite list of variable height children. /// Creates a viewport on an infinite list of variable height children.
/// ///
...@@ -395,8 +402,10 @@ class LazyBlockViewport extends RenderObjectWidget { ...@@ -395,8 +402,10 @@ class LazyBlockViewport extends RenderObjectWidget {
_RenderLazyBlock createRenderObject(BuildContext context) => new _RenderLazyBlock(); _RenderLazyBlock createRenderObject(BuildContext context) => new _RenderLazyBlock();
} }
@deprecated
class _LazyBlockParentData extends ContainerBoxParentDataMixin<RenderBox> { } class _LazyBlockParentData extends ContainerBoxParentDataMixin<RenderBox> { }
@deprecated
class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> { class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> {
_RenderLazyBlock({ _RenderLazyBlock({
Offset paintOffset: Offset.zero, Offset paintOffset: Offset.zero,
...@@ -471,6 +480,7 @@ class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> { ...@@ -471,6 +480,7 @@ class _RenderLazyBlock extends RenderVirtualViewport<_LazyBlockParentData> {
} }
} }
@deprecated
class _LazyBlockElement extends RenderObjectElement { class _LazyBlockElement extends RenderObjectElement {
_LazyBlockElement(LazyBlockViewport widget) : super(widget); _LazyBlockElement(LazyBlockViewport widget) : super(widget);
......
...@@ -35,6 +35,7 @@ import 'virtual_viewport.dart'; ...@@ -35,6 +35,7 @@ import 'virtual_viewport.dart';
/// * [ScrollableLazyList], a more efficient version of [ScrollableList]. /// * [ScrollableLazyList], a more efficient version of [ScrollableList].
/// * [LazyBlock], a more efficient version of [Block]. /// * [LazyBlock], a more efficient version of [Block].
/// * [ScrollableViewport], which only has one child. /// * [ScrollableViewport], which only has one child.
@Deprecated('use ListView instead')
class ScrollableList extends StatelessWidget { class ScrollableList extends StatelessWidget {
/// Creats a scrollable list of children that have equal size. /// Creats a scrollable list of children that have equal size.
/// ///
...@@ -381,6 +382,7 @@ class _VirtualListViewportElement extends VirtualViewportElement { ...@@ -381,6 +382,7 @@ class _VirtualListViewportElement extends VirtualViewportElement {
/// * [LazyListViewport]. /// * [LazyListViewport].
/// * [LazyBlockViewport]. /// * [LazyBlockViewport].
/// * [GridViewport]. /// * [GridViewport].
@deprecated
class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable { class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable {
/// Creates a virtual viewport onto a list of equally sized children. /// Creates a virtual viewport onto a list of equally sized children.
/// ///
...@@ -423,6 +425,7 @@ class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable ...@@ -423,6 +425,7 @@ class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable
/// ///
/// * [ScrollableList]. /// * [ScrollableList].
/// * [LazyBlock]. /// * [LazyBlock].
@Deprecated('use ListView.builder instead')
class ScrollableLazyList extends StatelessWidget { class ScrollableLazyList extends StatelessWidget {
/// Creates an infinite scrollable list of children that have equal size. /// Creates an infinite scrollable list of children that have equal size.
/// ///
...@@ -578,6 +581,7 @@ class ScrollableLazyList extends StatelessWidget { ...@@ -578,6 +581,7 @@ class ScrollableLazyList extends StatelessWidget {
/// ///
/// * [ListViewport]. /// * [ListViewport].
/// * [LazyBlockViewport]. /// * [LazyBlockViewport].
@deprecated
class LazyListViewport extends _VirtualListViewport with VirtualViewportFromBuilder { class LazyListViewport extends _VirtualListViewport with VirtualViewportFromBuilder {
/// Creates a virtual viewport onto an extremely large or infinite list of equally sized children. /// Creates a virtual viewport onto an extremely large or infinite list of equally sized children.
/// ///
......
// 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()));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment