0

Hello members am new bee to flutter i have dynamic movies list when i search movies list sometime i got 10 sometimes i got 2 values which correct but i want to have a button below this dynamic grid view which will be moving up and down with height of dynamic grid view here is what i wan t to achieve enter image description here

i have tried with Stack

Stack(
      children: [
        Positioned(
          top: 0,
          bottom: 0,
          left: 0,
          right: 0,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              
             
              
              Expanded(
                flex: 3,
                child: GridView.builder(
                  //shrinkWrap: true,
                  physics:NeverScrollableScrollPhysics(),
                  padding: EdgeInsets.only(bottom:  24, left: 15, right: 15),
                  gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                    childAspectRatio: 165 / 219,
                    mainAxisSpacing: 15,
                    crossAxisSpacing: 15,
                  ),
                  itemBuilder: (context, index) {
                    return _buildMoviesItem(context, state, index);
                  },
                  itemCount: movies.length,
                ),
              ),
             


            ],
          ),
        ),

        Positioned(
          bottom: 0,
          left: 0,
          right: 0,
          child: Text('Clear search results')
        ),
      ],
    );

but my button is always sticks t bottom never changed with dynamic grid view. thanks

Abu Qudama
  • 59
  • 1
  • 7

1 Answers1

0

use a column widget instead of Stack like

SingleChildScrollView(
 child: Column(
 mainAxisSize : MainAxisSize.min,
 children: [
   GridView.builder(
         //shrinkWrap: true,
         physics:NeverScrollableScrollPhysics(),
         padding: EdgeInsets.only(bottom:  24, left: 15, right: 15),
         gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
           crossAxisCount: 2,
            childAspectRatio: 165 / 219,
            mainAxisSpacing: 15,
            crossAxisSpacing: 15,
           ),
           itemBuilder: (context, index) {
              return _buildMoviesItem(context, state, index);
            },
             itemCount: movies.length,
            ),
        ),
    Text('Clear search results')
  ]
 )
)
Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30