Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/pages/chat/chat_event_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ChatEventList extends StatelessWidget {
child: OptionalSelectionArea(
isEnabled: PlatformInfos.isWeb && !controller.selectMode,
child: ChatScrollView(
key: PageStorageKey('ChatScrollView-${controller.room?.id}'),
events: events,
controller: controller,
constraints: constraints,
Expand Down
14 changes: 12 additions & 2 deletions lib/pages/chat/optional_selection_area.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

class OptionalSelectionArea extends StatelessWidget {
class OptionalSelectionArea extends StatefulWidget {
final Widget child;
final bool isEnabled;

Expand All @@ -10,8 +10,18 @@ class OptionalSelectionArea extends StatelessWidget {
required this.isEnabled,
});

@override
State<OptionalSelectionArea> createState() => _OptionalSelectionAreaState();
}

class _OptionalSelectionAreaState extends State<OptionalSelectionArea> {
final _bucket = PageStorageBucket();
@override
Widget build(BuildContext context) {
return isEnabled ? SelectionArea(child: child) : child;
return PageStorage(
bucket: _bucket,
child:
widget.isEnabled ? SelectionArea(child: widget.child) : widget.child,
);
Comment on lines +21 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain about this solution, any impact to the list ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PageStorage to save scroll position when widget rebuilds

}
}
Loading