mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Get older messages
This commit is contained in:
27
lib/ui/widgets/scroll_watcher.dart
Normal file
27
lib/ui/widgets/scroll_watcher.dart
Normal file
@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Scroll watcher
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
typedef OnReachBottomCallback = void Function();
|
||||
|
||||
class ScrollWatcher extends ScrollController {
|
||||
|
||||
// Callbacks
|
||||
OnReachBottomCallback onReachBottom;
|
||||
|
||||
ScrollWatcher({this.onReachBottom}) {
|
||||
addListener(_updatePosition);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _updatePosition() {
|
||||
|
||||
// Refresh bottom position
|
||||
if(position.pixels.floor() == position.maxScrollExtent.floor())
|
||||
onReachBottom();
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user