I want to use set show more and show less icon in last of text. I want to use set show more and show less icon in last of text. I want to use set show more and show less icon in last of text. I want to use set show more and show less icon in last of text.
this is my code
class HomeScreen extends StatelessWidget {
final String description =
"Flutter is Google’s mobile UI framework for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.";
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: const Text("Demo App"),
),
body: new Container(
child: new DescriptionTextWidget(text: description),
),
);
}
}
class DescriptionTextWidget extends StatefulWidget {
final String? text;
DescriptionTextWidget({@required this.text});
@override
_DescriptionTextWidgetState createState() => new _DescriptionTextWidgetState();
}
class _DescriptionTextWidgetState extends State<DescriptionTextWidget> {
String? firstHalf;
String? secondHalf;
Icon? ic=Icon(Icons.arrow_back);
bool flag = true;
@override
void initState() {
super.initState();
if (widget.text!.length > 50) {
firstHalf = widget.text!.substring(0, 50);
secondHalf = widget.text!.substring(50, widget.text!.length);
} else {
firstHalf = widget.text;
secondHalf = "";
}
}
@override
Widget build(BuildContext context) {
return new Container(
child: secondHalf!.isEmpty
? new Text(firstHalf!)
: new Column(
children: <Widget>[
// new Text(flag ? (firstHalf! + '...') : (firstHalf! + secondHalf!)),
flag==true?Column(children: [Text(firstHalf!),SizedBox(width: 10,) ,InkWell(
child: new Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Icon(Icons.forward),
],
),
onTap: () {
setState(() {
flag = !flag;
});
},
),],):Column(
children: [
Text( (firstHalf! + secondHalf!)),
InkWell(
child:
Icon(Icons.arrow_back),
onTap: () {
setState(() {
flag = !flag;
});
},
),
],
),
// new InkWell(
// child: new Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: <Widget>[
// new Text(
// flag ? "show more" : "show less",
// style: new TextStyle(color: Colors.blue),
// ),
// ],
// ),
// onTap: () {
// setState(() {
// flag = !flag;
// });
// },
// ),
],
),
);
}
}
but i cant it like this, please help me