Expandable Text/Expandable Description/See more-See less Animation Box in Flutter

Akshit Ostwal
3 min readDec 5, 2020

--

How to make expandable container / description / see more-see less widget in Flutter ??

How to make expanding (see more / see less) animation in flutter??

Let’s make a widget like the one below:

This is a very easy animation and can implemented using AnimatedCrossFade widget and setState()

So lets get started

1st lets make a Animated Expanding Container which we will be using inside the Expandable Text, we control the expanding animation within this container

You can use this widget to have any expanding widget not just Text

It take 3 things as a parameter:

only 3 parameters
  1. unexpandedWidget ( Widget to show when the state is unexpanded )
  2. expandedWidget ( Widget to show when the state is expanded )
  3. isExpanded ( Boolean true if state is expanded & vice-versa )

You can adjust the firstCurve and secondCurve according to your need here, personally I like to experiment with different curves with the animation.

Some of my favourite curves are Curves.bounceInOut and Curves.easeInOutExpo

2nd lets create a Expandable Text widget which we can use anywhere

It will need 3 parameters :

  1. Text ( the description string )
  2. maxLines ( the number of kine you want to display in expanded state )
  3. minLines ( the number of lines you want to display in unexpanded state )

--

--

Akshit Ostwal

Co-founder Orange Wallet ( Cross chain decentralised crypto wallet ) | Winner in more than dozens of Hackathons