Search code examples
flutterdartflutter-widget

Resize container on pressed (hide and show other widget)


Hi, is there any flutter widget that can do something like this?

enter image description here

When you click the arrow, the container resize and show other widget:

enter image description here


Solution

  • The expandable package might be helpful:

    Example taken from the package page:

    class ArticleWidget extends StatelessWidget {
      
      final Article article;
      
      ArticleWidget(this.article);
    
      @override
      Widget build(BuildContext context) {
        return ExpandablePanel(
          header: Text(article.title),
          collapsed: Text(article.body, softWrap: true, maxLines: 2, overflow: TextOverflow.ellipsis,),
          expanded: Text(article.body, softWrap: true, ),
          tapHeaderToExpand: true,
          hasIcon: true,
        );
      }
    }