I don’t know if stretching is the correct word to describe it.
But it looks like this.
"last message 👋👋" is the last message in this convo and the empty space below is the ‘stretching’. Once I release the touch from my screen it goes back to normal. I want to disable that ‘stretching’ so that nothing happens when the user overscrolls.
ListView code:
ListView.builder(
controller: _controller1,
physics: BouncingScrollPhysics(),
itemCount: snapshot.data!.docs.length, //snapshot from parent StreamBuilder
itemBuilder: (context, index) {
final allowedOrNot = index == 0
? true
: compareDate( // Userdefined function to check if the dates above messages should be displayed or not
currentSnap: snapshot.data!.docs[index]
.data()['serverTimeStamp'],
previousSnap: snapshot.data!.docs[index - 1]
.data()['serverTimeStamp']);
return Column(
children: [
allowedOrNot
? chatDater( // the date widget (above some messages to indicate the date of conversation)
data: dataForChatDater( // Userdefined function which returns Strings like 'Yesterday', 'Today' for the widget to display
snap: snapshot.data!.docs[index]
.data()['serverTimeStamp']),
)
: const SizedBox(
width: 0,
height: 0,
),
Align(
alignment:
snapshot.data!.docs[index].data()['sender'] ==
widget.usernameOfFriend
? Alignment.centerLeft
: Alignment.centerRight,
child: MessageBubble( // The ChatBubble widget used to display the messages
timestamp: snapshot.data!.docs[index]
.data()['serverTimeStamp'],
message: snapshot.data!.docs[index].data()['message'],
IsYou: snapshot.data!.docs[index].data()['sender'] ==
widget.usernameOfFriend
? false
: true,
),
),
],
);
},
),
2
Answers
It is natural behavior of
BouncingScrollPhysics
.If you don’t want to overscroll, you can change it to
NeverScrollableScrollPhysics
.Try
shrinkWrap:true
in your ListView.builder andmainAxisSize:MainAxisSize.min
inColumn
as follows: