Commit 1773e47b authored by Adam Barth's avatar Adam Barth Committed by GitHub

Remove a number of old scrolling widgets: (#8212)

- ScrollableList
 - ScrollableLazyList
 - LazyBlock
 - MaterialList

Clients should use ListView instead.
parent f93daa4f
...@@ -45,8 +45,7 @@ class OverscrollDemoState extends State<OverscrollDemo> { ...@@ -45,8 +45,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget body = new MaterialList( // ignore: DEPRECATED_MEMBER_USE Widget body = new Block( // ignore: DEPRECATED_MEMBER_USE
type: MaterialListType.threeLine,
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
scrollableKey: _scrollableKey, scrollableKey: _scrollableKey,
children: _items.map((String item) { children: _items.map((String item) {
...@@ -56,7 +55,7 @@ class OverscrollDemoState extends State<OverscrollDemo> { ...@@ -56,7 +55,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
title: new Text('This item represents $item.'), title: new Text('This item represents $item.'),
subtitle: new Text('Even more additional list item information appears on line three.') subtitle: new Text('Even more additional list item information appears on line three.')
); );
}) }).toList(),
); );
String indicatorTypeText; String indicatorTypeText;
......
...@@ -53,7 +53,6 @@ export 'src/material/ink_highlight.dart'; ...@@ -53,7 +53,6 @@ export 'src/material/ink_highlight.dart';
export 'src/material/ink_splash.dart'; export 'src/material/ink_splash.dart';
export 'src/material/ink_well.dart'; export 'src/material/ink_well.dart';
export 'src/material/input.dart'; export 'src/material/input.dart';
export 'src/material/list.dart';
export 'src/material/list_item.dart'; export 'src/material/list_item.dart';
export 'src/material/material.dart'; export 'src/material/material.dart';
export 'src/material/mergeable_material.dart'; export 'src/material/mergeable_material.dart';
......
...@@ -34,7 +34,6 @@ export 'src/rendering/flex.dart'; ...@@ -34,7 +34,6 @@ export 'src/rendering/flex.dart';
export 'src/rendering/flow.dart'; export 'src/rendering/flow.dart';
export 'src/rendering/image.dart'; export 'src/rendering/image.dart';
export 'src/rendering/layer.dart'; export 'src/rendering/layer.dart';
export 'src/rendering/list.dart';
export 'src/rendering/node.dart'; export 'src/rendering/node.dart';
export 'src/rendering/object.dart'; export 'src/rendering/object.dart';
export 'src/rendering/paragraph.dart'; export 'src/rendering/paragraph.dart';
......
// Copyright 2015 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/widgets.dart';
/// The kind of list items contained in a material design list.
///
/// See also:
///
/// * [ListItem]
/// * [kListItemExtent]
/// * <https://material.google.com/components/lists.html#lists-specs>
enum MaterialListType {
/// A list item that contains a single line of text.
oneLine,
/// A list item that contains a [CircleAvatar] followed by a single line of text.
oneLineWithAvatar,
/// A list item that contains two lines of text.
twoLine,
/// A list item that contains three lines of text.
threeLine
}
/// The vertical extent of the different types of material list items.
///
/// See also:
///
/// * [MaterialListType]
/// * [ListItem]
/// * [kListItemExtent]
/// * <https://material.google.com/components/lists.html#lists-specs>
Map<MaterialListType, double> kListItemExtent = const <MaterialListType, double>{
MaterialListType.oneLine: 48.0,
MaterialListType.oneLineWithAvatar: 56.0,
MaterialListType.twoLine: 72.0,
MaterialListType.threeLine: 88.0,
};
/// A scrollable list containing material list items.
///
/// Material list configures a [ScrollableList] with a number of default values
/// to match material design.
///
/// See also:
///
/// * [SliverList], which shows heterogeneous widgets in a list and makes the
/// list scrollable if necessary.
/// * [ListItem], to show content in a [MaterialList] using material design
/// conventions.
/// * [ScrollableList], on which this widget is based.
/// * [TwoLevelList], for lists that have subsections that can collapse and
/// expand.
/// * [GridView]
/// * <https://material.google.com/components/lists.html>
@Deprecated('use ListView instead')
class MaterialList extends StatelessWidget {
/// Creates a material list.
///
/// By default, has a type of [MaterialListType.twoLine].
MaterialList({
Key key,
this.initialScrollOffset,
this.onScrollStart,
this.onScroll,
this.onScrollEnd,
this.type: MaterialListType.twoLine,
this.children: const <Widget>[],
this.padding: EdgeInsets.zero,
this.scrollableKey
}) : super(key: key);
/// The scroll offset this widget should use when first created.
final double initialScrollOffset;
/// Called whenever this widget starts to scroll.
final ScrollListener onScrollStart;
/// Called whenever this widget's scroll offset changes.
final ScrollListener onScroll;
/// Called whenever this widget stops scrolling.
final ScrollListener onScrollEnd;
/// The kind of [ListItem] contained in this list.
final MaterialListType type;
/// The widgets to display in this list.
final Iterable<Widget> children;
/// The amount of space by which to inset the children inside the viewport.
final EdgeInsets padding;
/// The key to use for the underlying scrollable widget.
final Key scrollableKey;
@override
Widget build(BuildContext context) {
return new ScrollableList(
scrollableKey: scrollableKey,
initialScrollOffset: initialScrollOffset,
scrollDirection: Axis.vertical,
onScrollStart: onScrollStart,
onScroll: onScroll,
onScrollEnd: onScrollEnd,
itemExtent: kListItemExtent[type],
padding: const EdgeInsets.symmetric(vertical: 8.0) + padding,
children: children,
);
}
}
...@@ -10,6 +10,42 @@ import 'debug.dart'; ...@@ -10,6 +10,42 @@ import 'debug.dart';
import 'ink_well.dart'; import 'ink_well.dart';
import 'theme.dart'; import 'theme.dart';
/// The kind of list items contained in a material design list.
///
/// See also:
///
/// * [ListItem]
/// * [kListItemExtent]
/// * <https://material.google.com/components/lists.html#lists-specs>
enum MaterialListType {
/// A list item that contains a single line of text.
oneLine,
/// A list item that contains a [CircleAvatar] followed by a single line of text.
oneLineWithAvatar,
/// A list item that contains two lines of text.
twoLine,
/// A list item that contains three lines of text.
threeLine
}
/// The vertical extent of the different types of material list items.
///
/// See also:
///
/// * [MaterialListType]
/// * [ListItem]
/// * [kListItemExtent]
/// * <https://material.google.com/components/lists.html#lists-specs>
Map<MaterialListType, double> kListItemExtent = const <MaterialListType, double>{
MaterialListType.oneLine: 48.0,
MaterialListType.oneLineWithAvatar: 56.0,
MaterialListType.twoLine: 72.0,
MaterialListType.threeLine: 88.0,
};
/// A single row typically containing an icon and some text. /// A single row typically containing an icon and some text.
/// ///
/// List items are one to three lines of text optionally flanked by icons or /// List items are one to three lines of text optionally flanked by icons or
...@@ -32,7 +68,7 @@ import 'theme.dart'; ...@@ -32,7 +68,7 @@ import 'theme.dart';
/// ///
/// See also: /// See also:
/// ///
/// * [MaterialList], which takes a list of [ListItem] widgets and shows them /// * [ListView], which takes a list of [ListItem] widgets and shows them
/// as a scrolling list. /// as a scrolling list.
/// * [Card], which can be used with [Column] to show a few [ListItem]s. /// * [Card], which can be used with [Column] to show a few [ListItem]s.
/// * [CircleAvatar], which shows an icon representing a person. /// * [CircleAvatar], which shows an icon representing a person.
......
...@@ -10,7 +10,6 @@ import 'icon.dart'; ...@@ -10,7 +10,6 @@ import 'icon.dart';
import 'icons.dart'; import 'icons.dart';
import 'icon_theme.dart'; import 'icon_theme.dart';
import 'icon_theme_data.dart'; import 'icon_theme_data.dart';
import 'list.dart';
import 'list_item.dart'; import 'list_item.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart'; import 'theme_data.dart';
......
// Copyright 2015 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 'dart:math' as math;
import 'box.dart';
import 'object.dart';
import 'viewport.dart';
/// Parent data for use with [RenderList].
class ListParentData extends ContainerBoxParentDataMixin<RenderBox> { }
/// A linear layout of children intended for use as a virtual viewport.
///
/// Children are layout out in order along the main axis. If [itemExtent] is
/// non-null, each child is required to have exactly [itemExtent] extent in the
/// main axis. If [itemExtent] is null, each child is required to have the same
/// extent in the main axis as the list itself.
///
/// In the cross axis, the render list expands to fill the available space and
/// each child is required to have the same extent in the cross axis as the list
/// itself.
class RenderList extends RenderVirtualViewport<ListParentData> {
/// Creates a render list.
///
/// By default, the list is oriented vertically and anchored at the start.
RenderList({
List<RenderBox> children,
double itemExtent,
EdgeInsets padding,
int virtualChildCount,
Offset paintOffset: Offset.zero,
Axis mainAxis: Axis.vertical,
ViewportAnchor anchor: ViewportAnchor.start,
LayoutCallback<BoxConstraints> callback
}) : _itemExtent = itemExtent,
_padding = padding,
super(
virtualChildCount: virtualChildCount,
paintOffset: paintOffset,
mainAxis: mainAxis,
anchor: anchor,
callback: callback
) {
addAll(children);
}
/// The main-axis extent of each item in the list.
///
/// If [itemExtent] is null, the items are required to match the main-axis
/// extent of the list itself.
double get itemExtent => _itemExtent;
double _itemExtent;
set itemExtent (double newValue) {
if (_itemExtent == newValue)
return;
_itemExtent = newValue;
markNeedsLayout();
}
/// The amount of space by which to inset the children inside the list.
EdgeInsets get padding => _padding;
EdgeInsets _padding;
set padding (EdgeInsets newValue) {
if (_padding == newValue)
return;
_padding = newValue;
markNeedsLayout();
}
@override
void setupParentData(RenderBox child) {
if (child.parentData is! ListParentData)
child.parentData = new ListParentData();
}
double get _preferredExtent {
if (itemExtent == null)
return double.INFINITY;
final int count = virtualChildCount;
if (count == null)
return double.INFINITY;
double extent = itemExtent * count;
if (padding != null)
extent += padding.along(mainAxis);
return extent;
}
double _computeIntrinsicWidth() {
switch (mainAxis) {
case Axis.vertical:
assert(debugThrowIfNotCheckingIntrinsics());
return 0.0;
case Axis.horizontal:
final double width = _preferredExtent;
if (width.isFinite)
return width;
assert(debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
assert(mainAxis != null);
return null;
}
@override
double computeMinIntrinsicWidth(double height) {
return _computeIntrinsicWidth();
}
@override
double computeMaxIntrinsicWidth(double height) {
return _computeIntrinsicWidth();
}
double _computeIntrinsicHeight() {
switch (mainAxis) {
case Axis.vertical:
final double height = _preferredExtent;
if (height.isFinite)
return height;
assert(debugThrowIfNotCheckingIntrinsics());
return 0.0;
case Axis.horizontal:
assert(debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
assert(mainAxis != null);
return null;
}
@override
double computeMinIntrinsicHeight(double width) {
return _computeIntrinsicHeight();
}
@override
double computeMaxIntrinsicHeight(double width) {
return _computeIntrinsicHeight();
}
@override
void performLayout() {
switch (mainAxis) {
case Axis.vertical:
size = new Size(constraints.maxWidth,
constraints.constrainHeight(_preferredExtent));
break;
case Axis.horizontal:
size = new Size(constraints.constrainWidth(_preferredExtent),
constraints.maxHeight);
break;
}
if (callback != null)
invokeLayoutCallback<BoxConstraints>(callback);
double itemWidth;
double itemHeight;
double x = 0.0;
double dx = 0.0;
double y = 0.0;
double dy = 0.0;
switch (mainAxis) {
case Axis.vertical:
itemWidth = math.max(0.0, size.width - (padding == null ? 0.0 : padding.horizontal));
itemHeight = itemExtent ?? size.height;
x = padding != null ? padding.left : 0.0;
dy = itemHeight;
break;
case Axis.horizontal:
itemWidth = itemExtent ?? size.width;
itemHeight = math.max(0.0, size.height - (padding == null ? 0.0 : padding.vertical));
y = padding != null ? padding.top : 0.0;
dx = itemWidth;
break;
}
BoxConstraints innerConstraints =
new BoxConstraints.tightFor(width: itemWidth, height: itemHeight);
RenderBox child = firstChild;
while (child != null) {
child.layout(innerConstraints);
final ListParentData childParentData = child.parentData;
childParentData.offset = new Offset(x, y);
x += dx;
y += dy;
assert(child.parentData == childParentData);
child = childParentData.nextSibling;
}
}
}
...@@ -1452,12 +1452,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1452,12 +1452,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
}); });
return result; return result;
} }
@Deprecated(
'If you are using needsLayout for an assert, switch to debugNeedsLayout. '
'If you are using it for actual runtime logic, please contact the Flutter '
'team to let us know what your use case is. We intend to remove this getter.'
)
bool get needsLayout => _needsLayout;
bool _needsLayout = true; bool _needsLayout = true;
RenderObject _relayoutBoundary; RenderObject _relayoutBoundary;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'dart:ui' as ui show window; import 'dart:ui' as ui show window;
import 'package:flutter/foundation.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'box.dart'; import 'box.dart';
...@@ -337,132 +336,3 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin< ...@@ -337,132 +336,3 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin<
return false; return false;
} }
} }
/// A render object that shows a subset of its children.
///
/// The children of a viewport can layout to a larger size along the viewport's
/// [mainAxis] than the viewport itself. If that happens, only a subset of the
/// children will be visible through the viewport. The subset of children that
/// are visible can be controlled with the [paintOffset].
///
/// See also:
///
/// * [RenderList] (which arranges its children linearly)
/// * [RenderGrid] (which arranges its children into tiles)
/// * [RenderViewport] (which is easier to use with a single child)
abstract class RenderVirtualViewport<T extends ContainerBoxParentDataMixin<RenderBox>>
extends RenderViewportBase with ContainerRenderObjectMixin<RenderBox, T>,
RenderBoxContainerDefaultsMixin<RenderBox, T> {
/// Initializes fields for subclasses.
///
/// The [paintOffset] and [mainAxis] arguments must not be null.
RenderVirtualViewport({
int virtualChildCount,
LayoutCallback<BoxConstraints> callback,
Offset paintOffset: Offset.zero,
Axis mainAxis: Axis.vertical,
ViewportAnchor anchor: ViewportAnchor.start
}) : _virtualChildCount = virtualChildCount,
_callback = callback,
super(paintOffset, mainAxis, anchor);
/// The overall number of children this viewport could potentially display.
///
/// If null, the viewport might display an unbounded number of children.
int get virtualChildCount => _virtualChildCount;
int _virtualChildCount;
set virtualChildCount(int value) {
if (_virtualChildCount == value)
return;
_virtualChildCount = value;
markNeedsLayout();
}
/// Called during [layout] to determine the render object's children.
///
/// Typically the callback will mutate the child list appropriately, for
/// example so the child list contains only visible children.
LayoutCallback<BoxConstraints> get callback => _callback;
LayoutCallback<BoxConstraints> _callback;
set callback(LayoutCallback<BoxConstraints> value) {
if (value == _callback)
return;
_callback = value;
markNeedsLayout();
}
/// Throws an exception if asserts are enabled, unless the
/// [RenderObject.debugCheckingIntrinsics] flag is set.
///
/// This is a convenience function for subclasses to call from their
/// intrinsic-sizing functions if they don't have a good way to generate the
/// numbers.
@protected
bool debugThrowIfNotCheckingIntrinsics() {
assert(() {
if (!RenderObject.debugCheckingIntrinsics) {
throw new FlutterError(
'$runtimeType does not support returning intrinsic dimensions.\n'
'Calculating the intrinsic dimensions would require walking the entire '
'child list, which cannot reliably and efficiently be done for render '
'objects that potentially generate their child list during layout.'
);
}
return true;
});
return true;
}
@override
double computeMinIntrinsicWidth(double height) {
assert(debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
@override
double computeMaxIntrinsicWidth(double height) {
assert(debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
@override
double computeMinIntrinsicHeight(double width) {
assert(debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
@override
double computeMaxIntrinsicHeight(double width) {
assert(debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
@override
bool hitTestChildren(HitTestResult result, { Point position }) {
return defaultHitTestChildren(result, position: position + -_effectivePaintOffset);
}
void _paintContents(PaintingContext context, Offset offset) {
defaultPaint(context, offset + _effectivePaintOffset);
}
@override
void paint(PaintingContext context, Offset offset) {
context.pushClipRect(needsCompositing, offset, Point.origin & size, _paintContents);
}
@override
Rect describeApproximatePaintClip(RenderObject child) => Point.origin & size;
// Workaround for https://github.com/dart-lang/sdk/issues/25232
@override
void applyPaintTransform(RenderBox child, Matrix4 transform) {
super.applyPaintTransform(child, transform);
}
@override
void debugFillDescription(List<String> description) {
super.debugFillDescription(description);
description.add('virtual child count: $virtualChildCount');
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -29,7 +29,6 @@ export 'src/widgets/heroes.dart'; ...@@ -29,7 +29,6 @@ export 'src/widgets/heroes.dart';
export 'src/widgets/image.dart'; export 'src/widgets/image.dart';
export 'src/widgets/implicit_animations.dart'; export 'src/widgets/implicit_animations.dart';
export 'src/widgets/layout_builder.dart'; export 'src/widgets/layout_builder.dart';
export 'src/widgets/lazy_block.dart';
export 'src/widgets/locale_query.dart'; export 'src/widgets/locale_query.dart';
export 'src/widgets/media_query.dart'; export 'src/widgets/media_query.dart';
export 'src/widgets/modal_barrier.dart'; export 'src/widgets/modal_barrier.dart';
...@@ -55,7 +54,6 @@ export 'src/widgets/scroll_position.dart'; ...@@ -55,7 +54,6 @@ export 'src/widgets/scroll_position.dart';
export 'src/widgets/scroll_simulation.dart'; export 'src/widgets/scroll_simulation.dart';
export 'src/widgets/scroll_view.dart'; export 'src/widgets/scroll_view.dart';
export 'src/widgets/scrollable.dart'; export 'src/widgets/scrollable.dart';
export 'src/widgets/scrollable_list.dart';
export 'src/widgets/semantics_debugger.dart'; export 'src/widgets/semantics_debugger.dart';
export 'src/widgets/single_child_scroll_view.dart'; export 'src/widgets/single_child_scroll_view.dart';
export 'src/widgets/size_changed_layout_notifier.dart'; export 'src/widgets/size_changed_layout_notifier.dart';
...@@ -70,6 +68,5 @@ export 'src/widgets/title.dart'; ...@@ -70,6 +68,5 @@ export 'src/widgets/title.dart';
export 'src/widgets/transitions.dart'; export 'src/widgets/transitions.dart';
export 'src/widgets/unique_widget.dart'; export 'src/widgets/unique_widget.dart';
export 'src/widgets/viewport.dart'; export 'src/widgets/viewport.dart';
export 'src/widgets/virtual_viewport.dart';
export 'package:vector_math/vector_math_64.dart' show Matrix4; export 'package:vector_math/vector_math_64.dart' show Matrix4;
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