import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; class ContentWidget extends StatefulWidget { final String body; ContentWidget({required this.body}); @override _ContentWidgetState createState() => _ContentWidgetState(); } class _ContentWidgetState extends State { bool isExpanded = false; @override Widget build(BuildContext context) { final truncatedText = widget.body.length > 70 ? '${widget.body.substring(0, 70)}... ' : widget.body; return RichText( text: TextSpan( children: [ TextSpan( text: isExpanded ? widget.body : truncatedText, style: TextStyle( color: Color(0xFFA2A2A2), fontSize: 13, fontWeight: FontWeight.w400, height: 13 / 10, ), ), if (widget.body.length > 100) TextSpan( text: isExpanded ? 'See Less' : 'See More', style: TextStyle( color: Color(0xFF2B353E), fontSize: 13, fontWeight: FontWeight.w500, height: 13 / 10, ), recognizer: TapGestureRecognizer() ..onTap = () { setState(() { isExpanded = !isExpanded; }); }, ), ], ), ); } }