22// Use of this source code is governed by a BSD-style license that can be 
33// found in the LICENSE file. 
44
5+ import  'package:flutter/gestures.dart' ;
56import  'package:flutter/material.dart' ;
67
78/// Flutter code sample for [RefreshIndicator] . 
@@ -13,8 +14,9 @@ class RefreshIndicatorExampleApp extends StatelessWidget {
1314
1415  @override 
1516  Widget  build (BuildContext  context) {
16-     return  const  MaterialApp (
17-       home:  RefreshIndicatorExample (),
17+     return  MaterialApp (
18+       scrollBehavior:  const  MaterialScrollBehavior ().copyWith (dragDevices:  PointerDeviceKind .values.toSet ()),
19+       home:  const  RefreshIndicatorExample (),
1820    );
1921  }
2022}
@@ -40,17 +42,17 @@ class RefreshIndicatorExample extends StatelessWidget {
4042        // from the widget's children. 
4143        // 
4244        // By default this is set to `notification.depth == 0`, which ensures 
43-         // the only the scroll notifications from the first child  are listened to. 
45+         // the only the scroll notifications from the first scroll view  are listened to. 
4446        // 
4547        // Here setting `notification.depth == 1` triggers the refresh indicator 
4648        // when overscrolling the nested scroll view. 
4749        notificationPredicate:  (ScrollNotification  notification) {
4850          return  notification.depth ==  1 ;
4951        },
50-         child:  SingleChildScrollView (
51-           child :   Column ( 
52-             children :   < Widget > [ 
53-               Container (
52+         child:  CustomScrollView (
53+           slivers :   < Widget > [ 
54+             SliverToBoxAdapter ( 
55+               child :   Container (
5456                height:  100 ,
5557                alignment:  Alignment .center,
5658                color:  Colors .pink[100 ],
@@ -65,10 +67,12 @@ class RefreshIndicatorExample extends StatelessWidget {
6567                  ],
6668                ),
6769              ),
68-               Container (
70+             ),
71+             SliverToBoxAdapter (
72+               child:  Container (
6973                color:  Colors .green[100 ],
74+                 height:  300 ,
7075                child:  ListView .builder (
71-                   shrinkWrap:  true ,
7276                  itemCount:  25 ,
7377                  itemBuilder:  (BuildContext  context, int  index) {
7478                    return  const  ListTile (
@@ -78,8 +82,17 @@ class RefreshIndicatorExample extends StatelessWidget {
7882                  },
7983                ),
8084              ),
81-             ],
82-           ),
85+             ),
86+             SliverList .builder (
87+               itemCount:  20 ,
88+               itemBuilder:  (BuildContext  context, int  index) {
89+                 return  const  ListTile (
90+                   title:  Text ('Pull down here' ),
91+                   subtitle:  Text ("Refresh indicator won't trigger" ),
92+                 );
93+               }
94+             )
95+           ],
8396        ),
8497      ),
8598    );
0 commit comments