Created
March 14, 2020 12:06
-
-
Save vasyafromrussia/17d532593ae363e33d1c6045c2eba8b6 to your computer and use it in GitHub Desktop.
Flutter expandable text step 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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