@@ -10,11 +10,10 @@ import 'package:scrollview_observer/scrollview_observer.dart';
10
10
11
11
import '../load_more.dart' ;
12
12
import '../scroll_to_bottom.dart' ;
13
- import '../utils/composer_height_notifier.dart' ;
14
- import '../utils/keyboard_mixin.dart' ;
15
13
import '../utils/load_more_notifier.dart' ;
16
14
import '../utils/message_list_diff.dart' ;
17
15
import '../utils/typedefs.dart' ;
16
+ import 'sliver_spacing.dart' ;
18
17
19
18
/// Enum controlling the initial scroll behavior of the chat list.
20
19
enum InitialScrollToEndMode {
@@ -157,7 +156,7 @@ class ChatAnimatedList extends StatefulWidget {
157
156
158
157
/// State for [ChatAnimatedList] .
159
158
class _ChatAnimatedListState extends State <ChatAnimatedList >
160
- with TickerProviderStateMixin , WidgetsBindingObserver , KeyboardMixin {
159
+ with TickerProviderStateMixin {
161
160
final GlobalKey <SliverAnimatedListState > _listKey = GlobalKey ();
162
161
late final ChatController _chatController;
163
162
late final SliverObserverController _observerController;
@@ -245,7 +244,6 @@ class _ChatAnimatedListState extends State<ChatAnimatedList>
245
244
}
246
245
}
247
246
248
- @override
249
247
void onKeyboardHeightChanged (double height) {
250
248
// Reversed lists handle keyboard automatically
251
249
if (widget.reversed) {
@@ -320,8 +318,7 @@ class _ChatAnimatedListState extends State<ChatAnimatedList>
320
318
321
319
@override
322
320
Widget build (BuildContext context) {
323
- final bottomSafeArea = MediaQuery .of (context).padding.bottom;
324
- final builders = context.watch <Builders >();
321
+ final builders = context.read <Builders >();
325
322
326
323
// Define the SliverAnimatedList once as it's used for both
327
324
// reversed and non-reversed lists.
@@ -352,7 +349,7 @@ class _ChatAnimatedListState extends State<ChatAnimatedList>
352
349
// Order for CustomScrollView(reverse: true) -> Visual Bottom to Top
353
350
return < Widget > [
354
351
// Visually at the bottom (first in sliver list for reverse: true)
355
- _buildComposerHeightSliver (builders, bottomSafeArea ),
352
+ _buildComposerHeightSliver (context ),
356
353
if (widget.bottomSliver != null ) widget.bottomSliver! ,
357
354
sliverAnimatedList,
358
355
if (widget.onEndReached != null ) _buildLoadMoreSliver (builders),
@@ -371,7 +368,7 @@ class _ChatAnimatedListState extends State<ChatAnimatedList>
371
368
if (widget.onEndReached != null ) _buildLoadMoreSliver (builders),
372
369
sliverAnimatedList,
373
370
if (widget.bottomSliver != null ) widget.bottomSliver! ,
374
- _buildComposerHeightSliver (builders, bottomSafeArea ),
371
+ _buildComposerHeightSliver (context ),
375
372
// Visually at the bottom
376
373
];
377
374
}
@@ -440,20 +437,11 @@ class _ChatAnimatedListState extends State<ChatAnimatedList>
440
437
);
441
438
}
442
439
443
- Widget _buildComposerHeightSliver (Builders builders, double bottomSafeArea) {
444
- return Consumer <ComposerHeightNotifier >(
445
- builder: (context, heightNotifier, child) {
446
- return SliverPadding (
447
- padding: EdgeInsets .only (
448
- bottom:
449
- heightNotifier.height +
450
- (widget.bottomPadding ?? 0 ) +
451
- (widget.handleSafeArea == true ? bottomSafeArea : 0 ),
452
- ),
453
- );
454
- },
455
- );
456
- }
440
+ Widget _buildComposerHeightSliver (BuildContext context) => SliverSpacing (
441
+ bottomPadding: widget.bottomPadding,
442
+ handleSafeArea: widget.handleSafeArea,
443
+ onKeyboardHeightChanged: widget.reversed ? null : onKeyboardHeightChanged,
444
+ );
457
445
458
446
Widget _buildLoadMoreSliver (Builders builders) {
459
447
return SliverToBoxAdapter (
0 commit comments