Commit 2a5e528a authored by Kate Lovett's avatar Kate Lovett Committed by Flutter GitHub Bot

Fixing SliverOverlapAbsorber & SliverOverlapInjector child property (#44283)

parent b63683b6
...@@ -20,7 +20,7 @@ class PictureCachePage extends StatelessWidget { ...@@ -20,7 +20,7 @@ class PictureCachePage extends StatelessWidget {
return <Widget>[ return <Widget>[
SliverOverlapAbsorber( SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
child: SliverAppBar( sliver: SliverAppBar(
title: const Text('Picture Cache'), title: const Text('Picture Cache'),
pinned: true, pinned: true,
expandedHeight: 50.0, expandedHeight: 50.0,
......
...@@ -150,7 +150,7 @@ class TabsDemo extends StatelessWidget { ...@@ -150,7 +150,7 @@ class TabsDemo extends StatelessWidget {
return <Widget>[ return <Widget>[
SliverOverlapAbsorber( SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
child: SliverAppBar( sliver: SliverAppBar(
title: const Text('Tabs and scrolling'), title: const Text('Tabs and scrolling'),
actions: <Widget>[MaterialDemoDocumentationButton(routeName)], actions: <Widget>[MaterialDemoDocumentationButton(routeName)],
pinned: true, pinned: true,
......
...@@ -91,7 +91,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(BuildContex ...@@ -91,7 +91,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(BuildContex
/// // This is not necessary if the "headerSliverBuilder" only builds /// // This is not necessary if the "headerSliverBuilder" only builds
/// // widgets that do not overlap the next sliver. /// // widgets that do not overlap the next sliver.
/// handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), /// handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
/// child: SliverAppBar( /// sliver: SliverAppBar(
/// title: const Text('Books'), // This is the title in the app bar. /// title: const Text('Books'), // This is the title in the app bar.
/// pinned: true, /// pinned: true,
/// expandedHeight: 150.0, /// expandedHeight: 150.0,
...@@ -1317,7 +1317,7 @@ class SliverOverlapAbsorberHandle extends ChangeNotifier { ...@@ -1317,7 +1317,7 @@ class SliverOverlapAbsorberHandle extends ChangeNotifier {
/// A sliver that wraps another, forcing its layout extent to be treated as /// A sliver that wraps another, forcing its layout extent to be treated as
/// overlap. /// overlap.
/// ///
/// The difference between the overlap requested by the [child] sliver and the /// The difference between the overlap requested by the child [sliver] and the
/// overlap reported by this widget, called the _absorbed overlap_, is reported /// overlap reported by this widget, called the _absorbed overlap_, is reported
/// to the [SliverOverlapAbsorberHandle], which is typically passed to a /// to the [SliverOverlapAbsorberHandle], which is typically passed to a
/// [SliverOverlapInjector]. /// [SliverOverlapInjector].
...@@ -1331,14 +1331,20 @@ class SliverOverlapAbsorber extends SingleChildRenderObjectWidget { ...@@ -1331,14 +1331,20 @@ class SliverOverlapAbsorber extends SingleChildRenderObjectWidget {
/// [SliverOverlapAbsorberHandle]. /// [SliverOverlapAbsorberHandle].
/// ///
/// The [handle] must not be null. /// The [handle] must not be null.
///
/// The [child] must be a sliver.
const SliverOverlapAbsorber({ const SliverOverlapAbsorber({
Key key, Key key,
@required this.handle, @required this.handle,
@Deprecated(
'Use sliver instead. '
'This feature was deprecated after v1.10.16.'
)
Widget child, Widget child,
Widget sliver,
}) : assert(handle != null), }) : assert(handle != null),
super(key: key, child: child); // ignore: deprecated_member_use_from_same_package
assert(child == null || sliver == null),
// ignore: deprecated_member_use_from_same_package
super(key: key, child: sliver ?? child);
/// The object in which the absorbed overlap is recorded. /// The object in which the absorbed overlap is recorded.
/// ///
...@@ -1369,7 +1375,7 @@ class SliverOverlapAbsorber extends SingleChildRenderObjectWidget { ...@@ -1369,7 +1375,7 @@ class SliverOverlapAbsorber extends SingleChildRenderObjectWidget {
/// A sliver that wraps another, forcing its layout extent to be treated as /// A sliver that wraps another, forcing its layout extent to be treated as
/// overlap. /// overlap.
/// ///
/// The difference between the overlap requested by the [child] sliver and the /// The difference between the overlap requested by the child [sliver] and the
/// overlap reported by this widget, called the _absorbed overlap_, is reported /// overlap reported by this widget, called the _absorbed overlap_, is reported
/// to the [SliverOverlapAbsorberHandle], which is typically passed to a /// to the [SliverOverlapAbsorberHandle], which is typically passed to a
/// [RenderSliverOverlapInjector]. /// [RenderSliverOverlapInjector].
...@@ -1379,13 +1385,20 @@ class RenderSliverOverlapAbsorber extends RenderSliver with RenderObjectWithChil ...@@ -1379,13 +1385,20 @@ class RenderSliverOverlapAbsorber extends RenderSliver with RenderObjectWithChil
/// ///
/// The [handle] must not be null. /// The [handle] must not be null.
/// ///
/// The [child] must be a [RenderSliver]. /// The [sliver] must be a [RenderSliver].
RenderSliverOverlapAbsorber({ RenderSliverOverlapAbsorber({
@required SliverOverlapAbsorberHandle handle, @required SliverOverlapAbsorberHandle handle,
@Deprecated(
'Use sliver instead. '
'This feature was deprecated after v1.10.16.'
)
RenderSliver child, RenderSliver child,
RenderSliver sliver,
}) : assert(handle != null), }) : assert(handle != null),
// ignore: deprecated_member_use_from_same_package
assert(child == null || sliver == null),
_handle = handle { _handle = handle {
this.child = child; this.child = sliver ?? child;
} }
/// The object in which the absorbed overlap is recorded. /// The object in which the absorbed overlap is recorded.
...@@ -1486,9 +1499,17 @@ class SliverOverlapInjector extends SingleChildRenderObjectWidget { ...@@ -1486,9 +1499,17 @@ class SliverOverlapInjector extends SingleChildRenderObjectWidget {
const SliverOverlapInjector({ const SliverOverlapInjector({
Key key, Key key,
@required this.handle, @required this.handle,
@Deprecated(
'Use sliver instead. '
'This feature was deprecated after v1.10.16.'
)
Widget child, Widget child,
Widget sliver,
}) : assert(handle != null), }) : assert(handle != null),
super(key: key, child: child); // ignore: deprecated_member_use_from_same_package
assert(child == null || sliver == null),
// ignore: deprecated_member_use_from_same_package
super(key: key, child: sliver ?? child);
/// The handle to the [SliverOverlapAbsorber] that is feeding this injector. /// The handle to the [SliverOverlapAbsorber] that is feeding this injector.
/// ///
......
...@@ -379,7 +379,7 @@ void main() { ...@@ -379,7 +379,7 @@ void main() {
// This is not necessary if the "headerSliverBuilder" only builds // This is not necessary if the "headerSliverBuilder" only builds
// widgets that do not overlap the next sliver. // widgets that do not overlap the next sliver.
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
child: SliverAppBar( sliver: SliverAppBar(
title: const Text('Books'), // This is the title in the app bar. title: const Text('Books'), // This is the title in the app bar.
pinned: true, pinned: true,
expandedHeight: 150.0, expandedHeight: 150.0,
......
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