Commit 464a8e7c authored by Adam Barth's avatar Adam Barth Committed by GitHub

Formally deprecate Block and ScrollableViewport (#8166)

The replacements are ListView and SingleChildScrollView, respectively.
parent ae9bd5ea
...@@ -136,7 +136,6 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> { ...@@ -136,7 +136,6 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
List<CardModel> cardModels; List<CardModel> cardModels;
Map<MarkerType, Point> markers = new Map<MarkerType, Point>(); Map<MarkerType, Point> markers = new Map<MarkerType, Point>();
double markersScrollOffset = 0.0; double markersScrollOffset = 0.0;
ScrollListener scrollListener;
@override @override
void initState() { void initState() {
...@@ -173,8 +172,8 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> { ...@@ -173,8 +172,8 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
markers[MarkerType.topLeft] = box.localToGlobal(new Point(0.0, 0.0)); markers[MarkerType.topLeft] = box.localToGlobal(new Point(0.0, 0.0));
final Size size = box.size; final Size size = box.size;
markers[MarkerType.bottomRight] = box.localToGlobal(new Point(size.width, size.height)); markers[MarkerType.bottomRight] = box.localToGlobal(new Point(size.width, size.height));
final ScrollableState scrollable = Scrollable.of(target.currentContext); final Scrollable2State scrollable = Scrollable2.of(target.currentContext);
markersScrollOffset = scrollable.scrollOffset; markersScrollOffset = scrollable.position.pixels;
}); });
} }
......
...@@ -29,20 +29,16 @@ final ThemeData _kTheme = new ThemeData( ...@@ -29,20 +29,16 @@ final ThemeData _kTheme = new ThemeData(
); );
class PestoHome extends StatelessWidget { class PestoHome extends StatelessWidget {
static final GlobalKey<ScrollableState> scrollableKey = new GlobalKey<ScrollableState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new RecipeGridPage(recipes: kPestoRecipes, scrollableKey: scrollableKey); return new RecipeGridPage(recipes: kPestoRecipes);
} }
} }
class PestoFavorites extends StatelessWidget { class PestoFavorites extends StatelessWidget {
static final GlobalKey<ScrollableState> scrollableKey = new GlobalKey<ScrollableState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new RecipeGridPage(recipes: _favoriteRecipes.toList(), scrollableKey: scrollableKey); return new RecipeGridPage(recipes: _favoriteRecipes.toList());
} }
} }
...@@ -67,10 +63,9 @@ class PestoStyle extends TextStyle { ...@@ -67,10 +63,9 @@ class PestoStyle extends TextStyle {
// Displays a grid of recipe cards. // Displays a grid of recipe cards.
class RecipeGridPage extends StatefulWidget { class RecipeGridPage extends StatefulWidget {
RecipeGridPage({ Key key, this.recipes, this.scrollableKey }) : super(key: key); RecipeGridPage({ Key key, this.recipes }) : super(key: key);
final List<Recipe> recipes; final List<Recipe> recipes;
final GlobalKey<ScrollableState> scrollableKey;
@override @override
_RecipeGridPageState createState() => new _RecipeGridPageState(); _RecipeGridPageState createState() => new _RecipeGridPageState();
......
...@@ -432,7 +432,7 @@ class _RefreshProgressIndicatorPainter extends _CircularProgressIndicatorPainter ...@@ -432,7 +432,7 @@ class _RefreshProgressIndicatorPainter extends _CircularProgressIndicatorPainter
/// An indicator for the progress of refreshing the contents of a widget. /// An indicator for the progress of refreshing the contents of a widget.
/// ///
/// Typically used for swipe-to-refresh interactions. See [RefreshIndicator] for /// Typically used for swipe-to-refresh interactions. See [RefreshIndicator] for
/// a complete implementation of swipe-to-refresh driven by a [Scrollable] /// a complete implementation of swipe-to-refresh driven by a [Scrollable2]
/// widget. /// widget.
/// ///
/// See also: /// See also:
...@@ -442,7 +442,7 @@ class RefreshProgressIndicator extends CircularProgressIndicator { ...@@ -442,7 +442,7 @@ class RefreshProgressIndicator extends CircularProgressIndicator {
/// Creates a refresh progress indicator. /// Creates a refresh progress indicator.
/// ///
/// Rather than creating a refresh progress indicator directly, consider using /// Rather than creating a refresh progress indicator directly, consider using
/// a [RefreshIndicator] together with a [Scrollable] widget. /// a [RefreshIndicator] together with a [Scrollable2] widget.
RefreshProgressIndicator({ RefreshProgressIndicator({
Key key, Key key,
double value, double value,
......
...@@ -135,7 +135,7 @@ class InputValue { ...@@ -135,7 +135,7 @@ class InputValue {
/// * [InputField], which adds tap-to-focus and cut, copy, and paste commands. /// * [InputField], which adds tap-to-focus and cut, copy, and paste commands.
/// * [TextField], which is a full-featured, material-design text input field /// * [TextField], which is a full-featured, material-design text input field
/// with placeholder text, labels, and [Form] integration. /// with placeholder text, labels, and [Form] integration.
class EditableText extends Scrollable { class EditableText extends Scrollable { // ignore: DEPRECATED_MEMBER_USE
/// Creates a basic text input control. /// Creates a basic text input control.
/// ///
/// The [value] argument must not be null. /// The [value] argument must not be null.
...@@ -226,7 +226,7 @@ class EditableText extends Scrollable { ...@@ -226,7 +226,7 @@ class EditableText extends Scrollable {
} }
/// State for a [EditableText]. /// State for a [EditableText].
class EditableTextState extends ScrollableState<EditableText> implements TextInputClient { class EditableTextState extends ScrollableState<EditableText> implements TextInputClient { // ignore: DEPRECATED_MEMBER_USE
Timer _cursorTimer; Timer _cursorTimer;
bool _showCursor = false; bool _showCursor = false;
......
...@@ -192,7 +192,7 @@ class Focus extends StatefulWidget { ...@@ -192,7 +192,7 @@ class Focus extends StatefulWidget {
_FocusScope focusScope = key.currentContext.ancestorWidgetOfExactType(_FocusScope); _FocusScope focusScope = key.currentContext.ancestorWidgetOfExactType(_FocusScope);
if (focusScope != null) { if (focusScope != null) {
focusScope.focusState._setFocusedWidget(key); focusScope.focusState._setFocusedWidget(key);
Scrollable.ensureVisible(focusedContext); Scrollable.ensureVisible(focusedContext); // ignore: DEPRECATED_MEMBER_USE
Scrollable2.ensureVisible(focusedContext); Scrollable2.ensureVisible(focusedContext);
} }
} }
...@@ -360,7 +360,7 @@ class _FocusState extends State<Focus> { ...@@ -360,7 +360,7 @@ class _FocusState extends State<Focus> {
BuildContext focusedContext = _focusedWidget?.currentContext; BuildContext focusedContext = _focusedWidget?.currentContext;
if (focusedContext == null) if (focusedContext == null)
return; return;
Scrollable.ensureVisible(focusedContext); Scrollable.ensureVisible(focusedContext); // ignore: DEPRECATED_MEMBER_USE
Scrollable2.ensureVisible(focusedContext); Scrollable2.ensureVisible(focusedContext);
} }
......
...@@ -219,7 +219,7 @@ class ScrollPosition extends ViewportOffset { ...@@ -219,7 +219,7 @@ class ScrollPosition extends ViewportOffset {
beginBallisticActivity(0.0); beginBallisticActivity(0.0);
} }
/// Returns a description of the [Scrollable]. /// Returns a description of the [Scrollable2].
/// ///
/// Accurately describing the metrics typicaly requires using information /// Accurately describing the metrics typicaly requires using information
/// provided by the viewport to the [applyViewportDimension] and /// provided by the viewport to the [applyViewportDimension] and
......
...@@ -370,16 +370,7 @@ typedef void ScrollListener(double scrollOffset); ...@@ -370,16 +370,7 @@ typedef void ScrollListener(double scrollOffset);
/// Used by [Scrollable.snapOffsetCallback]. /// Used by [Scrollable.snapOffsetCallback].
typedef double SnapOffsetCallback(double scrollOffset, Size containerSize); typedef double SnapOffsetCallback(double scrollOffset, Size containerSize);
/// A base class for scrollable widgets. /// Will be removed soon.
///
/// If you have a list of widgets and want them to be able to scroll if there is
/// insufficient room, consider using [Block].
///
/// Commonly used classes that are based on Scrollable include [ScrollableList]
/// and [ScrollableViewport].
///
/// Widgets that subclass [Scrollable] typically use state objects that subclass
/// [ScrollableState].
class Scrollable extends StatefulWidget { class Scrollable extends StatefulWidget {
/// Initializes fields for subclasses. /// Initializes fields for subclasses.
/// ///
...@@ -1246,6 +1237,7 @@ class ScrollNotification extends Notification { ...@@ -1246,6 +1237,7 @@ class ScrollNotification extends Notification {
/// * [ScrollableList], if you have many identically-sized children. /// * [ScrollableList], if you have many identically-sized children.
/// * [GridView], if your children are in a grid pattern. /// * [GridView], if your children are in a grid pattern.
/// * [LazyBlock], if you have many children of varying sizes. /// * [LazyBlock], if you have many children of varying sizes.
@Deprecated('use SingleChildScrollView')
class ScrollableViewport extends StatelessWidget { class ScrollableViewport extends StatelessWidget {
/// Creates a simple scrolling widget that has a single child. /// Creates a simple scrolling widget that has a single child.
/// ///
...@@ -1379,6 +1371,7 @@ class ScrollableViewport extends StatelessWidget { ...@@ -1379,6 +1371,7 @@ class ScrollableViewport extends StatelessWidget {
/// * [LazyBlock], if you have many children with varying heights. /// * [LazyBlock], if you have many children with varying heights.
/// * [ScrollableList], if all your children are the same height. /// * [ScrollableList], if all your children are the same height.
/// * [ScrollableViewport], if you only have one child. /// * [ScrollableViewport], if you only have one child.
@Deprecated('use ListView instead')
class Block extends StatelessWidget { class Block extends StatelessWidget {
/// Creates a scrollable array of children. /// Creates a scrollable array of children.
Block({ Block({
......
...@@ -28,7 +28,7 @@ void main() { ...@@ -28,7 +28,7 @@ void main() {
new RefreshIndicator( new RefreshIndicator(
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
refresh: refresh, refresh: refresh,
child: new Block( child: new Block( // ignore: DEPRECATED_MEMBER_USE
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
children: <String>['A', 'B', 'C', 'D', 'E', 'F'].map((String item) { children: <String>['A', 'B', 'C', 'D', 'E', 'F'].map((String item) {
return new SizedBox( return new SizedBox(
...@@ -55,7 +55,7 @@ void main() { ...@@ -55,7 +55,7 @@ void main() {
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
refresh: refresh, refresh: refresh,
location: RefreshIndicatorLocation.bottom, location: RefreshIndicatorLocation.bottom,
child: new Block( child: new Block( // ignore: DEPRECATED_MEMBER_USE
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
children: <Widget>[ children: <Widget>[
new SizedBox( new SizedBox(
...@@ -81,7 +81,7 @@ void main() { ...@@ -81,7 +81,7 @@ void main() {
new RefreshIndicator( new RefreshIndicator(
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
refresh: refresh, refresh: refresh,
child: new Block( child: new Block( // ignore: DEPRECATED_MEMBER_USE
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
children: <Widget>[ children: <Widget>[
new SizedBox( new SizedBox(
...@@ -107,7 +107,7 @@ void main() { ...@@ -107,7 +107,7 @@ void main() {
new RefreshIndicator( new RefreshIndicator(
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
refresh: holdRefresh, // this one never returns refresh: holdRefresh, // this one never returns
child: new Block( child: new Block( // ignore: DEPRECATED_MEMBER_USE
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
children: <Widget>[ children: <Widget>[
new SizedBox( new SizedBox(
...@@ -149,7 +149,7 @@ void main() { ...@@ -149,7 +149,7 @@ void main() {
new RefreshIndicator( new RefreshIndicator(
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
refresh: refresh, refresh: refresh,
child: new Block( child: new Block( // ignore: DEPRECATED_MEMBER_USE
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
children: <Widget>[ children: <Widget>[
new SizedBox( new SizedBox(
...@@ -192,7 +192,7 @@ void main() { ...@@ -192,7 +192,7 @@ void main() {
new RefreshIndicator( new RefreshIndicator(
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
refresh: refresh, refresh: refresh,
child: new Block( child: new Block( // ignore: DEPRECATED_MEMBER_USE
scrollableKey: scrollableKey, scrollableKey: scrollableKey,
children: <Widget>[ children: <Widget>[
new SizedBox( new SizedBox(
......
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