1

I want animation on grid expand. At first gird shows 4 items only and later on click button grid shows all item i.e more than 4 (with an animation). In a row there are 4 items.

bool click = false;
 return Container(
      width: double.infinity,
      child: GridView.builder(
    physics: NeverScrollableScrollPhysics(),
    shrinkWrap: true,
    gridDelegate:
        new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
    itemBuilder: (BuildContext context, int index) {
      return GestureDetector(
        onTap: () {
          if (index % 3 == 0) {
            Navigator.of(context).push(SlideLeftRoute(
                widget: Search(
              "Restaurant",
              isSearchFromTextField: false,
              list: list,
            )));
          } else {
            Navigator.of(context)
                .push(SlideLeftRoute(widget: RestaurantDetail()));
          }
        },
        child: Container(
          child: Column(
            children: <Widget>[
              Container(
                padding: EdgeInsets.all(10),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(4),
                  color: HexColor(widget._homeScopedModel.homePageModel
                      .category[index].color),
                ),
                child: SvgPicture.asset(
                  'assets/images/restaurant.svg',
                  width: 30,
                  height: 30,
                  color: CustomColor.white,
                ),
              ),
              SizedBox(
                height: 10,
              ),
              Text(
                widget._homeScopedModel.homePageModel.category[index].name,
                style: TextStyle(
                  color: CustomColor.black,
                  fontSize: 12.0,
                  fontFamily: 'SFProDisplay',
                  fontWeight: FontWeight.w400,
                ),
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      );
    },
    itemCount:
        click ? widget._homeScopedModel.homePageModel.category.length : 4,
      ),
    );


//on click image
new GestureDetector(
                          child: RotatedBox(
                            quarterTurns: click ? 2 : 0,
                            child: SvgPicture.asset(
                              'assets/images/icon_down.svg',
                              width: 15,
                              height: 15,
                              color: CustomColor.grey,
                            ),
                          ),
                          onTap: () {
                            click = !click;
                            setState(() {});
                          },
                        ),

Before grid expand

After grid Expand

On Click image the grid view will expand. I want slide down and slide up animation on click image. I tried Animated Container but it doesn't work for me. I found animation only on expanding other view like below. how to animate collapse elements in flutter

sanjay
  • 165
  • 2
  • 12
  • 1
    Did you try SizeTransition? – Hassan Saleh Jul 25 '19 at 06:35
  • What all did you try ? and what is the problem you faced ? – Sukhi Jul 25 '19 at 08:06
  • @Sukhi i want when the animation slide down when the user click on down arrow and should need to be expanded as in second picture. and when on click up arrow slide up animation and goes to first picture position. – sanjay Jul 25 '19 at 11:30
  • I get the requirement. However, StackOverflow isn't a free code-writing/editing/enhancement service, and expects you to try to solve your own problem first. Please update your question to show what you have already tried, showing the specific problem you are facing in a [minimal, complete, and verifiable example](https://stackoverflow.com/help/minimal-reproducible-example). For further information, please see [how to ask](https://stackoverflow.com/help/how-to-ask) a good question, and take the [tour](https://stackoverflow.com/tour) of the site. – Sukhi Jul 25 '19 at 11:31
  • I agree with @Sukhi, try to present what you have tried and where are stuck so that the community will be able to understand and suggest a solution. – MαπμQμαπkγVπ.0 Jul 20 '21 at 00:47

1 Answers1

0

I understood your question. I think you should try to use expansionTile, expandable and there are much more things like that. Whether you want you can create your own animating expandable widget with animations in stateful widget

Wodota ML
  • 76
  • 5