jonataslaw / readmore

A Flutter plugin than allow expand and collapse text dynamically
MIT License
257 stars 79 forks source link

Add support for text callback #8

Closed andreaselia closed 3 years ago

andreaselia commented 3 years ago

This fixes #1 to an extent. I don't have any use cases in mind where you'd want a callback for each state so I added support for a single state callback.

My use case for this is having the functionality to have 2 lines of text with an inline read more but when pressed the read more takes you to another screen with the full text rather than expanding the text.

jonataslaw commented 3 years ago

Hi, thanks for your contribution. I removed a typo where it was 'pressed' instead of 'onPressed', and ended up changing the method name for the callback, and entering the display status in the callback.

LGTM

andreaselia commented 3 years ago

@jonataslaw is it not an issue that the state is always updated no matter what you want to do with the callback?

My use case above would mean that if I were to do something like:

callback: (val) => Navigator.push(context, MaterialPageRoute(builder: (context) {
  return HelpScreen();
})),

It would change state before navigating, and then the state would still be changed afterwards.

Also, on an unrelated note, and I'd appreciate some advice if possible. I do seem to have the issue of "Read more" and the "more" going onto a 3rd line when the line limit is set to 2. It seems to be an issue with constraints.maxWidth as taking away ~3 from this resolves the issue for myself.