Jaime Blasco

Add nested scroll example

... ... @@ -11,6 +11,7 @@ import 'modals/modal_fit.dart';
import 'modals/modal_inside_modal.dart';
import 'modals/modal_will_scope.dart';
import 'modals/modal_with_navigator.dart';
import 'modals/modal_with_nested_scroll.dart';
import 'modals/modal_with_scroll.dart';
import 'examples/cupertino_share.dart';
... ... @@ -219,7 +220,7 @@ class _MyHomePageState extends State<MyHomePage> {
scrollController: scrollController),
)),
ListTile(
title: Text('Cupertino Modal with WillPopScope'),
title: Text('Modal with WillPopScope'),
onTap: () => showCupertinoModalBottomSheet(
expand: true,
context: context,
... ... @@ -228,6 +229,15 @@ class _MyHomePageState extends State<MyHomePage> {
ModalWillScope(
scrollController: scrollController),
)),
ListTile(
title: Text('Modal with Nested Scroll'),
onTap: () => showCupertinoModalBottomSheet(
expand: true,
context: context,
builder: (context, scrollController) =>
NestedScrollModal(
scrollController: scrollController),
)),
],
),
),
... ...
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class NestedScrollModal extends StatelessWidget {
final ScrollController scrollController;
const NestedScrollModal({Key key, this.scrollController}) : super(key: key);
@override
Widget build(BuildContext context) {
return NestedScrollView(
physics: ScrollPhysics(parent: PageScrollPhysics()),
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverList(
delegate: SliverChildListDelegate(
[
Container(height: 300, color: Colors.blue),
],
),
),
];
},
body: ListView.builder(
controller: scrollController,
itemBuilder: (context, index) {
return Container(
height: 100,
color: index.isOdd ? Colors.green : Colors.orange,
);
},
itemCount: 12,
));
}
}
... ...