Jaime Blasco

Add nested scroll example

@@ -11,6 +11,7 @@ import 'modals/modal_fit.dart'; @@ -11,6 +11,7 @@ import 'modals/modal_fit.dart';
11 import 'modals/modal_inside_modal.dart'; 11 import 'modals/modal_inside_modal.dart';
12 import 'modals/modal_will_scope.dart'; 12 import 'modals/modal_will_scope.dart';
13 import 'modals/modal_with_navigator.dart'; 13 import 'modals/modal_with_navigator.dart';
  14 +import 'modals/modal_with_nested_scroll.dart';
14 import 'modals/modal_with_scroll.dart'; 15 import 'modals/modal_with_scroll.dart';
15 16
16 import 'examples/cupertino_share.dart'; 17 import 'examples/cupertino_share.dart';
@@ -219,7 +220,7 @@ class _MyHomePageState extends State<MyHomePage> { @@ -219,7 +220,7 @@ class _MyHomePageState extends State<MyHomePage> {
219 scrollController: scrollController), 220 scrollController: scrollController),
220 )), 221 )),
221 ListTile( 222 ListTile(
222 - title: Text('Cupertino Modal with WillPopScope'), 223 + title: Text('Modal with WillPopScope'),
223 onTap: () => showCupertinoModalBottomSheet( 224 onTap: () => showCupertinoModalBottomSheet(
224 expand: true, 225 expand: true,
225 context: context, 226 context: context,
@@ -228,6 +229,15 @@ class _MyHomePageState extends State<MyHomePage> { @@ -228,6 +229,15 @@ class _MyHomePageState extends State<MyHomePage> {
228 ModalWillScope( 229 ModalWillScope(
229 scrollController: scrollController), 230 scrollController: scrollController),
230 )), 231 )),
  232 + ListTile(
  233 + title: Text('Modal with Nested Scroll'),
  234 + onTap: () => showCupertinoModalBottomSheet(
  235 + expand: true,
  236 + context: context,
  237 + builder: (context, scrollController) =>
  238 + NestedScrollModal(
  239 + scrollController: scrollController),
  240 + )),
231 ], 241 ],
232 ), 242 ),
233 ), 243 ),
  1 +import 'package:flutter/cupertino.dart';
  2 +import 'package:flutter/material.dart';
  3 +
  4 +class NestedScrollModal extends StatelessWidget {
  5 + final ScrollController scrollController;
  6 +
  7 + const NestedScrollModal({Key key, this.scrollController}) : super(key: key);
  8 +
  9 + @override
  10 + Widget build(BuildContext context) {
  11 + return NestedScrollView(
  12 +
  13 + physics: ScrollPhysics(parent: PageScrollPhysics()),
  14 + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
  15 + return <Widget>[
  16 + SliverList(
  17 + delegate: SliverChildListDelegate(
  18 + [
  19 + Container(height: 300, color: Colors.blue),
  20 + ],
  21 + ),
  22 + ),
  23 + ];
  24 + },
  25 + body: ListView.builder(
  26 + controller: scrollController,
  27 + itemBuilder: (context, index) {
  28 + return Container(
  29 + height: 100,
  30 + color: index.isOdd ? Colors.green : Colors.orange,
  31 + );
  32 + },
  33 + itemCount: 12,
  34 + ));
  35 + }
  36 +}