How to create gesture in sliver grid

926 views
Skip to first unread message

Suriya Suriya

unread,
Jun 27, 2019, 3:41:41 AM6/27/19
to Flutter Development (flutter-dev)
Hi, I'm new to flutter. Somebody, please guide me how to add gesture detector to sliver grid.Thanks in advance

Bhanuka Isuru

unread,
Jun 27, 2019, 4:29:00 AM6/27/19
to Flutter Development (flutter-dev)
return CustomScrollView(

 

  slivers
: <Widget>[

   
SliverList(

     
delegate: SliverChildBuilderDelegate((context, i) {

Final items = 10;

       
return GridView.builder(

          itemCount
: items.length,

          shrinkWrap
: true,

          primary
: false,

          gridDelegate
:

             
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),

          itemBuilder
: (context, i) {

           
final item = items[i];

           
return _builderItem(item);

         
},

       
);

     
}, childCount: pIntValues.length),

   
)

 
],

);


 

Widget _builderItem(DataRegister item) {

 
return GridTile(

    child
: GestureDetector(

      onTap
: () => Navigator.push(

          context
,

         
MaterialPageRoute(

              builder
: (context) => assets3(item.i, widget.isQuick))),

      child
: Column(

        children
: [

         
SvgPicture.asset(

           
'assets/images/Register/Loc-icon-${item.i}.svg',

            height
: 50.0,

            color
: const Color(0xFFE27023),

         
),

         
Expanded(

            child
: Text(

              item
.d,

              textAlign
: TextAlign.center,

              style
: TextStyle(fontSize: 10.0),

           
),

         
),

       
],

     
),

   
),

 
);

}

Suriya Suriya

unread,
Jun 27, 2019, 5:40:48 AM6/27/19
to Flutter Development (flutter-dev)
How to gesture to sliver grid


On Thursday, June 27, 2019 at 1:11:41 PM UTC+5:30, Suriya Suriya wrote:

Suriya Suriya

unread,
Jun 27, 2019, 5:41:26 AM6/27/19
to Flutter Development (flutter-dev)
how to add gesture for the sliver grid

Suriya Suriya

unread,
Jun 27, 2019, 5:43:36 AM6/27/19
to Flutter Development (flutter-dev)

My gesture detector child is a sliver grid. How to do?

On Thursday, June 27, 2019 at 1:11:41 PM UTC+5:30, Suriya Suriya wrote:

Frank zheng

unread,
Jun 27, 2019, 6:03:21 AM6/27/19
to Flutter Development (flutter-dev)
Maybe you can ddd Containers to your sliver gird first. And then you can add GestureDetector to your Container, eg:
Enter code here...        

SliverGrid.count(
          children: <Widget>[
            Container(
             color: Colors.red,
             height: 150.0,
             alignment: Alignment.topRight,
             child: GestureDetector(onTap: (){}, child: Container(color: Colors.black, height: 50,),),
             ),
            Container(color: Colors.purple, height: 150.0),
            Container(color: Colors.green, height: 150.0),
          ],
          crossAxisCount: 3,
        ),

Suriya Suriya

unread,
Jun 27, 2019, 6:08:17 AM6/27/19
to Flutter Development (flutter-dev)
I need to add a gesture to the entire grid

Suriya Suriya

unread,
Jun 27, 2019, 6:20:43 AM6/27/19
to Flutter Development (flutter-dev)
I'm using custom scroll view in that it placing search bar, sliver grid. I need to add gesture for that grid only.How to add gesture for that sliver grid

Bhanuka Isuru

unread,
Jun 27, 2019, 11:27:45 PM6/27/19
to Flutter Development (flutter-dev)
Do you find a solution bro?

On Thursday, June 27, 2019 at 1:11:41 PM UTC+5:30, Suriya Suriya wrote:

Suriya Suriya

unread,
Jun 28, 2019, 1:38:34 AM6/28/19
to Flutter Development (flutter-dev)
No, I don't find any solutions


On Thursday, June 27, 2019 at 1:11:41 PM UTC+5:30, Suriya Suriya wrote:
Reply all
Reply to author
Forward
0 new messages