Skip to content

Commit b29b58c

Browse files
If it's working Don't touch it
1 parent abcbfc2 commit b29b58c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

lib/widgets/message_list.dart

+16-11
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,13 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
515515
return;
516516
}
517517

518+
// Might be used in the future
519+
// ignore: unused_local_variable
518520
final viewportDimension = scrollController.position.viewportDimension;
519521
final currentScroll = scrollController.position.pixels;
520522

521523
// If we're one viewportDimension from the bottomList, scroll to it
522-
if (currentScroll + viewportDimension > 0) {
524+
if (currentScroll + 300 > 0) {
523525

524526
// Calculate initial scroll parameters
525527
final distanceToCenter = scrollController.position.pixels;
@@ -537,17 +539,18 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
537539

538540
// Wait for the layout to settle so scrollController.position.pixels is updated properly
539541

540-
541-
final distanceToBottom = scrollController.position.maxScrollExtent - scrollController.position.pixels;
542-
final durationMsToBottom = math.min(1500, (1000 * distanceToBottom / 8000).ceil());
542+
var distanceToBottom = scrollController.position.maxScrollExtent - scrollController.position.pixels;
543+
final durationMsToBottom = math.min(200, (1000 * distanceToBottom / 8000).ceil());
543544
// If we go too fast, we'll overscroll.as
544545

545546
// After scroling to the bottom sliver, scroll to the bottom of the bottomSliver if we're not already there
546-
if (distanceToBottom > 36) {
547+
while (distanceToBottom > 36) {
547548
await scrollController.animateTo(
548549
scrollController.position.maxScrollExtent,
549550
duration: Duration(milliseconds: durationMsToBottom),
550551
curve: Curves.ease);
552+
distanceToBottom = scrollController.position.maxScrollExtent - scrollController.position.pixels;
553+
await Future<void>.delayed(const Duration(milliseconds: 50));
551554
}
552555

553556
}
@@ -783,7 +786,6 @@ class ScrollToBottomButton extends StatelessWidget {
783786
final distanceToCenter = scrollController.position.pixels;
784787
final durationMsAtSpeedLimit = (1000 * distanceToCenter / 8000).ceil();
785788
final durationMs = math.max(300, durationMsAtSpeedLimit);
786-
787789
// If we're not at the bottomSliver,scroll to it
788790
if(distanceToCenter<36){
789791
await scrollController.animateTo(
@@ -796,18 +798,21 @@ class ScrollToBottomButton extends StatelessWidget {
796798
// Wait for the layout to settle so scrollController.position.pixels is updated properly
797799
await Future<void>.delayed(const Duration(milliseconds: 50));
798800

799-
800-
final distanceToBottom = scrollController.position.maxScrollExtent - scrollController.position.pixels;
801-
final durationMsToBottom = math.min(1000, (1000 * distanceToBottom / 8000).ceil());
801+
var distanceToBottom = scrollController.position.maxScrollExtent - scrollController.position.pixels;
802+
final durationMsToBottom = math.min(1000, (1200 * distanceToBottom / 8000).ceil());
802803
// If we go too fast, we'll overscroll.
803-
804804
// After scroling to the bottom sliver, scroll to the bottom of the bottomSliver if we're not already there
805-
if (distanceToBottom > 36) {
805+
var count = 0;
806+
while (distanceToBottom > 36) {
806807
await scrollController.animateTo(
807808
scrollController.position.maxScrollExtent,
808809
duration: Duration(milliseconds: durationMsToBottom),
809810
curve: Curves.easeOut);
811+
await Future<void>.delayed(const Duration(milliseconds: 50));
812+
distanceToBottom = scrollController.position.maxScrollExtent - scrollController.position.pixels;
813+
count++;
810814
}
815+
print("count: $count");
811816
}
812817

813818
@override

0 commit comments

Comments
 (0)