jonataslaw / readmore

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

Bug in listivew #74

Open MOhsain opened 9 hours ago

MOhsain commented 9 hours ago

I have a readMore widget in the listview. I have a long text. When i click on it expanded. And scroll to bottom and read all the text. Now when i click on read less, The text is collapse. But now my current listview index is 7, 8. It should be on the place item where i click on read more or read less.

MohsinIkram-Auxilium commented 7 hours ago

Here is my code, you can try it at your end too.

class ProfileScreen extends StatefulWidget { const ProfileScreen({super.key});

@override State createState() => _ProfileScreenState(); }

class _ProfileScreenState extends State { var moreLessStyle = const TextStyle( overflow: TextOverflow.ellipsis, color: AppColors.themeColor, fontWeight: FontWeight.w400, fontFamily: AppStrings.inter, decoration: TextDecoration.underline, decorationColor: AppColors.themeColor, decorationThickness: 1.0, fontSize: 14);

@override Widget build(BuildContext context) { // return Scaffold( // body: SafeArea( // child: Column( // children: [ // HeaderWidget( // title: "Profile", // onBackPress: (){ // Get.back(); // }, // ) // ], // )), // ); return Scaffold( body: SafeArea( child: Column( children: [ HeaderWidget( title: "Profile", onBackPress: () { Get.back(); }, ), Expanded( child: ListView.builder( itemCount: 200, itemBuilder: (BuildContext context, int index) { //return Text("df"); return Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Align( alignment: Alignment.topLeft, child: ReadMoreText( "$index / Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...Automatically load more items when the user scrolls to the bottom of the list. In order to achieve this, we need to use NotificationListener<ScrollNotification ...", textAlign: TextAlign.start, trimMode: TrimMode.Line, trimLines: 3, colorClickableText: AppColors.themeColor, trimCollapsedText: 'Read more', trimExpandedText: 'Read less', style: const TextStyle( overflow: TextOverflow.ellipsis, color: AppColors.primaryTextColor, fontWeight: FontWeight.w400, fontFamily: AppStrings.inter, fontSize: 14), moreStyle: moreLessStyle, lessStyle: moreLessStyle, ), ), Divider() ], ), ); }, ), ), ], )), ); } }