Skip to content

Instantly share code, notes, and snippets.

@vasyafromrussia
Created March 14, 2020 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasyafromrussia/17d532593ae363e33d1c6045c2eba8b6 to your computer and use it in GitHub Desktop.
Save vasyafromrussia/17d532593ae363e33d1c6045c2eba8b6 to your computer and use it in GitHub Desktop.
Flutter expandable text step 1
class ExpandableText extends StatefulWidget {
final TextSpan textSpan;
final TextSpan moreSpan;
final int maxLines;
const ExpandableText({
Key key,
this.textSpan,
this.maxLines,
this.moreSpan,
})
: assert(textSpan != null),
assert(maxLines != null),
assert(moreSpan != null),
super(key: key);
@override
_ExpandableTextState createState() => _ExpandableTextState();
}
class _ExpandableTextState extends State<ExpandableText> {
static const String _ellipsis = "\u2026\u0020"; // Unicode symbols for "… "
bool _isExpanded = false;
GestureRecognizer get _tapRecognizer => TapGestureRecognizer()
..onTap = () {
setState(() {
_isExpanded = !_isExpanded;
});
};
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
// TODO: we'll do some maths here
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment